servlets

How do I make client browser stop requesting an expired session id?

I am developing a Java web application that will run on a secure intranet and does not require a user login. The application does, however, keep conversational state in an HttpSession. User input is not persisted to the database until they explicitly click a save button at some stage in the conversation. Until then, their input is retain...

Send Email or Logged Error on 404 and 500 Http Error Spring MVC

I have been thinking, how is it possible for me to send an email when a particular HTTP Error code happens in my Spring MVC Web app. Please take a look at my web.xml configuration. It works fine and redirects me to the particular error page. <web-app ...> <servlet> <servlet-name>mvc-dispatcher</servlet-name> <servlet-...

How to configure a filter to work after servlet processing?

The problem in brief is that i want a certain filter to run after servlet processing to check for a value in the request attributes and based on that value it redirects to a certain URl. In web.xml, i have put the element the last in order, and in side the doFilter method i call "chain.doFilter(request, response);" the first line then...

Servlet 3.0 asynchronous

Hi All! What's the diffrent between servlet 3.0 asynchronous feature against: old servlet impl doGet(request,response) { Thread t = new Thread(new Runnable() void run(){ // heavy processing response.write(result) } } In servlet 3.0 if I waste a thread to do heavy processing - I earn one more thread in the co...

Good Book on Understanding JEE/J2EE security

Hi, I have been using and learning Servlets and JSP without giving enough thoughts on J2EE/JEE security. Now, I wanted to upgrade my knowledge and add security into the web apps that I am building. I have searched over SO post but cant find enough resource to read on about Security. Can you share me some links or tutorials where I co...

404 error page for all url contexts

Hi there. I have a custom 404 error page in my java web app. (declared using web.xml) It is working in all the cases. But if the url pattern comes like for example : www.mysite.com/admin/cannotfind the custom error page doesnt locate the images and css java script files for 404 custom error page. But it get works for normal url like www...

Java deflate response

Hello all I want to make a filter for tomcat to deflate all responces of certain MIME type. Any guidelines? ... String ae = request.getHeader("accept-encoding"); if (ae != null && ae.indexOf("deflate") != -1) { deflate response...????? } chain.doFilter(request, res); ...

JAXWS servlet endpoint and principal propagation

Hello, I'm trying to develop webservice authentication by checking hash_ID given in wsdl URL. I use servlet webservice (JAXWS, without ejb). I've extended WSServlet class. In doGet method I check if the given hashId is valid and if so, I do the programmatic login. The problem is that after login, principal is not propagated from servlet...

When does the ServletContext return a null RequestDispatcher?

The api for ServletContext#getRequestDispatcher() says: This method returns null if the ServletContext cannot return a RequestDispatcher. and Returns: a RequestDispatcher object that acts as a wrapper for the resource at the specified path, or null if the ServletContext cannot return a RequestDispatcher For what reason wou...

Tomcat serving static content

Hi, I have a Spring app and I'm wondering the best way to serve static content. I have tried the following: <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>/static/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>app</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> Th...

How to pre-compile jsp tag files?

http://download.oracle.com/javaee/1.4/tutorial/doc/JSPTags6.html says: Tag files can also be compiled into Java classes and bundled as a tag library. This is useful when you wish to distribute a binary version of the tag library without the original source. If you choose this form of packaging, you must use a tool that ...

URL mapping in servlet filter

I already have two filters, which typically checks for a valid session. If session is valid it ll redirect to the ExpenseDetailsManagement.html else ExpenseManagementLogin.html. The web.xml config looks like, <filter> <filter-name>ExpenseAuthentication</filter-name> <filter-class>com.pricar.hibernate.ExpenseAuthentication</...

Serializer is not defined in XSQL configuration file

I am trying to write some custom Serializers for an Oracle XSQL Servlet. I'm trying to keep my two serializers within the local .ear because they are still being developed and tested and I don't want to hurt production code. However, I am getting the following error XML-25021: Serializer XLSv2 is not defined in XSQL configuration file ...

Setting path X in "ZipFile zipfile = new ZipFile("X");"

I'm having problems setting the path of the zip file, X, in ZipFile zipfile = new ZipFile("X");. I don't want to hardcode the path such that it becomes ZipFile zipfile = new ZipFile("C:/docs/data.zip");. I want to do something like : ZipFile zipfile = new ZipFile(getServletContext().getResourceAsStream("/WEB-INF/" + request.getAttrib...

accessing the .java file from .jsp file in Eclipse

in eclipse IDE how can i access a java class from .jsp exactly like accessing a servlet from a jsp file ? in other word, what should i replace with question marks "????????" <form name="myForm" action="???????????????" method="post"> </form> when i run engine.java file from "mypackage" package tomcat application servers shows this add...

Java Netbeans error

I've been following the 'Netbeans E-Commerce tutorial', and have am currently on this step: http://netbeans.org/kb/docs/javaee/ecommerce/entity-session.html I have fully configured my Window 7 account as per that page, with NetBeans 6.9.1, Glassfish server and MySQL. I'm getting an error 500 when executing 'Category' page (log extract ...

Setting up AJAX progress bar

Ok im new to AJAX. Kind of know about the lifecycle of a request, IE uses ActiveXObject stuff like that. However now im faced with a real world problem. I have a servlet running in the background that performs a number of tasks and i would like to display a progress bar to show where the process is up to and to also show that something ...

HttpServletRequest get POST data

I am HTTP POST-ing to URL http://laptop:8080/apollo/services/rpc?cmd=execute with POST data { "jsondata" : "data" } Http request has Content-Type of application/json; charset=UTF-8 How do I get the POST data (jsondata) from HttpServletRequest? If I enumerate the request params, I can only see one param, which is "cmd", not the POST...

Access request object in JavaScript

I have a form in jsp. I have to populate it based on the request object (from the servlet). How do i use Java Script for accessing request object attributes or if you can suggest me any other better way to populate form dynamically? ...

What logging can be used to log in GWT shared code?

There are three types of code in a GWT project: Client code (GWT client / javascript) Server code (servlet container / java) Shared code (GWT client & servlet container / javascript & java) Logging framework usable for each type: Client - gwt-log Server - slf4j Shared - ??? I'd like to have a write once for the shared code that c...