How do I prevent the output of my JSP or Servlet pages from being cached by the browser?
JSP Interview Questions and Answers
(Continued from previous question...)
23. How do I prevent the output of my JSP or Servlet pages from being cached by the browser?
You will need to set the appropriate HTTP header attributes to prevent the dynamic content output by the JSP page from being cached by the browser. Just execute the following scriptlet at the beginning of your JSP pages to prevent them from being cached at the browser. You need both the statements to take care of some of the older browser versions.
(Continued on next question...)
Other Interview Questions
- What is a JSP and what is it used for?
- What is difference between custom JSP tags and beans?
- What are the two kinds of comments in JSP and what's the difference between them.
- What is JSP technology?
- What is JSP page?
- What are the implicit objects?
- How many JSP scripting elements and what are they?
- Why are JSP pages the preferred API for creating a web-based client program?
- Is JSP technology extensible?
- Can we use the constructor, instead of init(), to initialize servlet?
- How can a servlet refresh automatically if some new data has entered the database?
- The code in a finally clause will never fail to execute, right?
- How many messaging models do JMS provide for and what are they?
- What information is needed to create a TCP Socket?
- What Class.forName will do while loading drivers?
- How to Retrieve Warnings?
- How many JSP scripting elements are there and what are they?
- In the Servlet 2.4 specification SingleThreadModel has been deprecated, why?
- What are stored procedures? How is it useful?
- How do I include static files within a JSP page?
- Why does JComponent have add() and remove() methods but Component does not?
- How can I enable session tracking for JSP pages if the browser has disabled cookies?
- How do I prevent the output of my JSP or Servlet pages from being cached by the browser?
- How do you restrict page errors display in the JSP page?
- What JSP lifecycle methods can I override?
- How do I perform browser redirection from a JSP page?
- How does JSP handle run-time exceptions?
- How do I use comments within a JSP page?
- Is it possible to share an HttpSession between a JSP and EJB? What happens when I change a value in the HttpSession from inside an EJB?
- How can I implement a thread-safe JSP page?
- How can I declare methods within my JSP page?
- Can I stop JSP execution while in the midst of processing a request?
- Can a JSP page process HTML FORM data?
- Is there a way to reference the "this" variable within a JSP page?
- How do you pass control from one JSP page to another?
- Is there a way I can set the inactivity lease period on a per-session basis?
- How does a servlet communicate with a JSP page?
- How do I include static files within a JSP page?
- Can you make use of a ServletOutputStream object from within a JSP page?
- Can a JSP page instantiate a serialized bean?
- What is JSP?
- How do I mix JSP and SSI #include?
- How do I mix JSP and SSI #include? What is the difference between include directive & jsp:include action?
- How do you prevent the Creation of a Session in a JSP Page and why? What is the difference between include directive & jsp:include action?
- How do I use a scriptlet to initialize a newly instantiated bean?
- How can I set a cookie and delete a cookie from within a JSP page?
- How do you connect to the database from JSP?
- What is the page directive is used to prevent a JSP page from automatically creating a session?
- How do you delete a Cookie within a JSP?
- Can we implement an interface in a JSP?
- What is the difference between ServletContext and PageContext?
- What is the difference in using request.getRequestDispatcher() and context.getRequestDispatcher()?
- How to pass information from JSP to included JSP?
- How is JSP include directive different from JSP include action.
- Can we override the jspInit(), _jspService() and jspDestroy() methods?
- Why is _jspService() method starting with an '_' while other life cycle methods do not?
- Explain the life cycle of JSP?
- What happens when a page is statically included in another JSP page?
- A JSP page, include.jsp, has a instance variable "int a", now this page is statically included in another JSP page, index.jsp, which has a instance variable "int a" declared. What happens when the index.jsp page is requested by the client?
- Can you override jspInit() method? If yes, In which cases?
- What is the difference between directive include and jsp include?
- What is the difference between RequestDispatcher and sendRedirect?
- How does JSP handle runtime exceptions?
- How can my application get to know when a HttpSession is removed?
|