I'm experimenting the basic concepts of Servlet technology with my below simple setup.
I have a welcome.jsp defined under webContent in eclipse and my welcome.jsp looks like
My Controller is defined as below
Now I have few questions based on the above setup
1) As you see session="false" in jsp, and when I used scriptlet like <%= request.getSession(false) %>, I see "null" being printed but if I use pageContext.request.session.id, the session is not null. How does session = "false" influences scriptlets and implicit objects and why the behavior is different
2) If session really exists, even when session=false is used, when I disabled cookies in FireFox browser and click on "click Me" hyperlink, the control goes to Controller, but in the servlet, I see 'No Session Created" being displayed. Which means session was not created and probably because I used false is getSession(false). But if I enable cookies, with the same setup, I get Session ID = << some value>> being printed and this is same as the session what printed through pageContext.request.session.id in the jsp.
So when cookies disabled, how can pageContext.request.session.id actually printed session id , but not in servlet and when cookies enabled, the same session id is displayed in both cases.
My question is why there is no impact in jsp, when cookies are disabled.
This has been covered in other posts. All adding session="false" to the JSP does is to prevent a scriptlet variable named session from being created that refers to the session. it does not prevent the session from existing in any way, shape or form.
I understand. But my question is when cookies are disabled in FireFox, why the session is null in servlet, but not in JSP. I understand that cookies are used for session management. But if session is null in servlet, then should it not be null in jsp as well or viceversa. Is that the behavior of FireFox only ? I have not tried in other browsers though.
No holds barred. And no bars holed. Except this tiny ad:
Create Edit Print & Convert PDF Using Free API with Java