How to disable browser caching for specific JSP?

It is possible to keep the browser from caching a JSP page response. The following hints added to the response header seem to prevent most modern browsers from pulling pages out of cache when the same URL is “hit”: <%    response.setHeader( “Pragma”, “no-cache” );    response.setHeader( “Cache-Control”, “no-cache” );    response.setDateHeader( “Expires”, 0 ); ...

Servlet’s Life moment Listeners

Scenario  Listener interface  Event type  You want to know if an attribute in a web app context has been added, removed, or replaced. javax.servlet.ServletContextAttributeListener attributeAdded attributeRemoved attributeReplaced ServletContextAttributeEvent  You want to know how many concurrent users there are. In other words, you want to track the active sessions. (We cover sessions in detail in the ...

RequestDispatcher

A RequestDispatcher object can forward a client’s request to a resource or include the resource itself in the response back to the client. A resource can be another servlet, or an HTML file, or a JSP file, etc. You can also think of a RequestDispatcher object as a wrapper for the resource located at a given path ...

JSP include standard action and include directive

S.No.  include directive  JSP include <jsp:include page="..." ></jsp:include>..........  1. Content of the file specified in the attribute “file” of the include directive will be pasted as it is at tranlation time , where include directive is used in the jsp  At runtime, the includED file will be executed and the response will be included in the includING ...

Invalid Statements

1. Using the method isUserInRole(), overrides any declarative authorization related to method in which it is invoked – isUserInRole() method itself doesn’t do any authorization. 2. name - value attribute is mandatory for  3. Benefits of the JSP precompilation is , it avoids initialization on the first request. 4.             java.lang.Error             /error.html           - valid value ...

forward and sendRedirect

Whenever there is a request from the client (or browser) to the server, the server container creates two objects 1. request 2. response and pass these objects to the servlet along with other parameters if needed.    S.No.  RequestDispatcher.forward  HttpServletResponse.sendRedirect  1. the request is forwarded to other resource(say B) in the same context, B does some ...

flushing buffer means?

Flushing means the data processed so far can go to the client even if the rest of the page isn’t done yet. It’s useful when you have a lot of data to send like in a download. flush=true : means send to client flush=false : means wait.