DEVFYI - Developer Resource - FYI

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?

JSP Interview Questions and Answers


(Continued from previous question...)

44. 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?

By default, a JSP page will automatically create a session for the request if one does not exist.
However, sessions consume resources and if it is not necessary to maintain a session, one should not be created. For example, a marketing campaign may suggest the reader visit a web page for more information. If it is anticipated that a lot of traffic will hit that page, you may want to optimize the load on the machine by not creating useless sessions.

(Continued on next question...)

Other Interview Questions