servlets

What is the syntax for EL that accesses List with object?

I'm having tough time figure out how to display object's properties in ArrayList using EL expression. Many tutorial outside shows simple example like: List<String> test = new ArrayList<String>(); request.setAttribute("test", test); test.add("moo"); And it works fine. <p>${test[0]}</p> When the ArrayList contains actual object with...

Automatically synchronize Java servlet in Eclipse?

I'm using Vaadin framework and everything is setup fine using the Book of Vaadin. When I alter source code it automatically builds and synchronizes the server which I can see in the Server tab, however when I refresh my browser window nothing is changed. The only time when I can see the change is when I select my module in the Server ta...

difference between servlet lifecycle and filter lifecycle

is there any difference between servlet and filter lifecycle?. ...

Best way for long-time login with Java Servlets

In my web appication i need to recognize signed in users even if they restart the browser ("Remember me" function of web sites). What is the best practice to achieve this using Java Servlet API? I've considered the following options: Using long-term HttpSession sessions and storing user identifier as an attribute of the session. This...

How to display images using HTML created by servlets on Jetty web server?

Hi, I am trying to display images using an HTML page created by a servlet. I am using Jetty 6.18 as the web server. The problem is I'm not sure where to store the image files and how to register them (if needed), since the HTML returned to the client is generated by a servlet. Let's say I want to write a tag <img src="what_to_write_h...

programmatically put the calling servlet into the action of an HTML Form

in a controller servlet I have the doGet as protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { RequestDispatcher view = req.getRequestDispatcher("views/insert_item.jsp"); view.forward(req, res); } in the view insert_item.jsp I want to post back to the same calling servlet b...

Should Maven package different WARs for different application servers?

I am just starting to package my web application project as a WAR file and am running into differences between the configuration for Tomcat vs Jetty vs JBoss vs Websphere, etc. Should I try to configure some super-smart an all-in-one WAR file, or should I create different Maven profiles to create different WARs for each app server? ...

Corupt ZIP file servlet response for multiple file archive

I'm trying ZIP a bundle of File's and return ZIP through a servlet. This works fine if I just have one file but when I try to add more it seems they are just being appended to the first ZipEntry and thus the zip archive gets corrupted. private void writeZipResponse(HttpServletResponse response, List<File> bundle) { try { By...

Why use the j_username and SPRING_SECURITY_LAST_USERNAME variables?

Why do this? <input type="text" name="j_username" value="${SPRING_SECURITY_LAST_USERNAME}"> instead of this? <input type="text" name="username" value=""> What's the value of the j_username and SPRING_SECURITY_LAST_USERNAME variables? ...

How to get response from this filter?

The following servlet filter is getting called, but not able to give the correct response. I just looping inside the filter itself. The Browser says, The page isn't redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete. ExpenseAuthenticationFilter.class...

Using both @RequestBody and normal parameters

Hi, I am using spring 3 controllers with a flex client. I am now using @RequestBody in order to pass xml's to the server. How can i pass additional parameters? Thank you. ...

JAX-WS Servlet destroy()

I have some resources that I allocate when my web service is created that I need to be released (for example, I need to flush and close file streams when the servlet is being shut down). How can I have code executed when the JAX-WS servlet's destroy() method is called? ...

Tomcat ignores my custom error servlet/page

Hello experts, I have an issue which drives me crazy. Not sure it this is a bug in Tomcat or just my plain stupidity but here goes. I have a custom error servlet set up, something like this. The setup works and if I simulate exceptions or 404 errors etc the servlet runs, the error page is displayed corectly, the response code is either...

Detect network disconnection in WAS servlet?

I have a servlet running in WAS 6.1.0.21, which provides the csv file downloading for the Java client implemented based on Apache HttpClient. One feature of the servlet is to know whether the client has been downloaded successfully. The main problem here is to detect the connection states. Through testing I found that in some situations...

Store and retrieve word documents with MySQL

Hi Fellas, I need to store and retrieve MS Word documents into MySQL 5.1 with Servlets. I've the code to upload a file, but I don't know can I feed into the table. I've used BLOB for the field I've to insert .doc files. Here's my code snippet to upload files: protected void doPost(HttpServletRequest request, HttpServletResponse respo...

Clean Working directory of Tomcat in Eclipse

When I work in on an servlet application in Eclipse, I have to choose Clean Working Directory in the server tab of Eclipse for the changes to be visible in the browser. Is there any way to make sure that I only have to build my servlet and the changes are immediately visible? ...

JSP JavaBean and Servlets?

Hi everyone, I'm in a bit of a dilemma on how to connect the above mentioned three technologies. I'm still a student so please bare with me on this as I try to explain my problem. For an assignment I have to create a simple form that uses JSP for the view with the Model and the controller being Servlets, the communication needs to be do...

How to portably read configuration data from a servlet

I'm writing a Java servlet that needs to read some site-specific configuration data; I would like it to be easily accessible/modifiable by the sysadmins at deployment time. There is no sensible default, so the data needs to be provided by the site admin. It consists of a few string key/value pairs (think Properties). It would only be r...

WAR vs EAR for web application with no EJB?

I have a JEE web application that does not make use of EJBs. I am targeting Jetty/Tomcat for deployment some of the time and thus need a WAR packaging. However, I am also target JBoss and Websphere some of the time. My understanding is that full-blown JEE application servers can take either EAR or WAR formats. When would I use one ...

What is a servlet's "display-name" for?

The <display-name> element appears to be a valid sub-element of the <servlet> element as per the Servlet 2.5 deployment descriptor XSD. That is, according to Eclipse's XML validator, this: <servlet> <servlet-name>FooServlet</servlet-name> <display-name>FooServlet</display-name> <servlet-class>com.bar.servlet.FooServlet</serv...