This week's book giveaway is in the Beginning Java forum.
We're giving away four copies of Get Programming with Java (MEAP only) and have Peggy Fisher on-line!
See this thread for details.
Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Disabling cookies in Firefox does not create session in servlet, but not in JSP  RSS feed

Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

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, 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 in the jsp.

So when cookies disabled, how can 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.

Posts: 67197
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Rajesh Karanam
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Those are the largest trousers in the world! Especially when next to this ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!