servlets

upload file with java servlet to app engine

Hi I would like to be able to have the user upload short audio samples to my app-engine application and store them in the provided datastore. I'm using the Java servlet version. My problem is using a multi-part form to upload a file. Using the normal request.getParameter() method returns null with multi-part forms. I have read abo...

Using a custom Servlet oriented framework, too many servlets, is this an issue

In our application, we structure different web applications by Servlet. There are many, many Servlets and Filters in our applications. We already use different frameworks but not for this particular legacy web application. One issue is that one application/servlet is completely separate from another. If you were to redesign your appl...

How do I get the current time in a different TimeZone in Java?

OK - I feel pretty dumb asking such a basic question, but hey. I'm trying to get the current time in a different timezone in a Java webapp. I've tried the following obvious solution: in my servlet, Calendar localCalendar = Calendar.getInstance(myBean.getTimeZone()); then I pass the calendar object through to a JSP as a request attribu...

attributeRemoved not being called after session.invalidate

I have a object that implements the HttpSessionAttributeListener, and as you'd expect it does some work when certain objects are added, replaced and removed from the session. I thought that the if the session is ended [session.invalidate()], each object from that session is removed from the session as so the attributeRemoved() method ...

error appears in jdeveloper 11g 11112

hi all, i need help on compiling my project in jdeveloper 11g. previously my application (jsp+servlets) works smoothly in jdeveloper 10g with oc4j (deploys in WAR file). but since i migrate to jdeveloper 11g, it appears several errors like this : <Nov 27, 2009 1:13:50 PM WIT> <Error> <Deployer> <BEA-149265> <Failure occurred in the exec...

Putting a servlet's reponse in a struts template's tile

Hi, I've set up my servlet to get invoked through a struts action and the result is that it writes html to the screen. However, I'm using a template system (lets say header, content, footer) and would only like to write to the content title ie. keep the header and footer. Does anybody know if this is possible? Thanks, Gearoid. ...

Is is necessary to close the input stream returned from HttpServletRequest ?

I've got some production code that does something like: HttpServletRequest httpServletRequest ... DataInputStream dis = new DataInputStream(httpServletRequest.getInputStream()) These streams are never closed explicitly. I'm assuming here that the servlet container manages this (JBOss Web). What is the correct way to handle this? ...

Glassfish hangs when serving multiple blob-images from an imageservlet

In my JSP/HTML files i use the following servlet to get blob-images from the MySQL-database. <img src="/image?id=1" /> Image servlet This is mapped to a imageservlet, who: - gets a stateless session-bean injected - uses the session-bean to lookup a product, based on the id passed in to the servlet - streams this image out as the resp...

Problem while executing ajax

I am trying to do a simple application using Ajax and servlet. But when i was trying to execute the application, it is not working. Please go through the code and let me know what would be the problem? function createRequest() { alert("hai createRequest()"); try { req=new XMLHttpRequest(); } catch(trymicrosoft) { tr...

How to restrict what files a desktop app can download from an online server

The closest example I can think of is iTunes. I'm thinking about a system where a server stores loads of files, and each user only has access to those they have paid for. Using a desktop app, they can download these to their local PC where they are stored as regular files. How might one approach this? I can see a couple of possible opti...

J2EE war file redeployment changes not reflected

Hi all, I created the the file index.jsp as below <form action="" method="POST"><br> First Name: <input type="text" name="firstName" size="20"><br> Surname: <input type="text" name="surname" size="20"><br> <input type="submit" value="Submit"><br> </form> I export it to .war and everything works fine. Then later I modified...

servlet result display in jsp page

How to forward the servlet output to jsp page? That means the result will be displayed in the JSP page. ...

Compiling a servlet in Windows XP

How do I compile and run a servlet from the Command Prompt? I got an error when I tried to compile using Apache Tomcat 6.0.16. What is the exact command I should be using? ...

Clean up after servlet if init() failed

I have an Initializer class that implements the ServletContextListener interface. In its contextInitialized() method, I initialize some global classes that have to be destroyed, otherwise the servlet cannot be unloaded. However, when the servlet's init() method throws a ServletException, the contextDestroyed() method never gets called -...

Should I close the servlet outputstream ?

Am I responsible for closing the HttpServletResponse.getOutputStream() (or the getWriter() or even the inputstream) or should I leave it to the container ? protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { OutputStream o = response.getOutputStream(); ... ...

How to call a servlet from a jQuery's $.ajax() function

I am trying to call a servlet from jQuery's .ajax() function. At the moment I don't think I am even calling the servlet or passing paramaters to it, however lots of Googling doesn't seem to have helped. Any ideas? This is my html: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <script type="text...

displaying multiple records by using resultset

how to display multiple records from database having the same field value by using result set statement ...

servlet compiling error

Can anyone please help me with compiling servlet? Do I have to include path for JDK or Tomcat or both to compile servlet in command prompt? ...

Sharing a static object between a servlet and a webservice

I have a servlet which handles http get requests that I'd like to be able to share an object which is also used by a webservice im developing. They are both on the same tomcat server within the same web-app container. Im not sure best how to do it any ideas ? ...

Apache/Tomcat site nesting

Hello, I have two standalone sites in tomcat webapps folder $TOMCAT_HOME/siteA which is registered in DNS as siteA.example.com and $TOMCAT_HOME/siteB which is NOT registered in DNS Both sites are written in Java/Servlets. Is there a way to setup apache/tomcat/mod-rewrite to call siteB like so? siteA.example.com/siteB Does this l...