Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP automatically creating HttpSessions  RSS feed

 
Andy Hahn
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do JSPs automatically create sessions? I like to develop low overhead, highly efficient applications that do not require unnecessary configuration setup such as sticky session load balancers. If it's part of the servlet spec, is it possible to voice my concern to the servlet spec decision makers somewhere?

The only way I know of to get around the issue is to add this to the top of every JSP:
<%@page session="false" %>

Seems to be working according to jconsole.

Thanks
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37180
515
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andy,
What's the problem with including that in each JSP?

The spec designers are very interested in backward compatibility and are unlikely to change the default even if you voice a concern. I suppose they might be open to adding an entry in the web.xml to do that. But it seems redundant.
 
Andy Hahn
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no problem with adding that line of code to each JSP, and you are correct, I also doubt the spec designers will change anything. I guess an undesirable trend I have been seeing lately is the way libraries just use session when they feel like it. Struts2 and java-facebook-api for example.

I write code assuming users will 1) turn cookies off and 2) bookmark URLS and not want to deal with jsessionid. I assume that so that I have to code for it. I believe use of session is a "feature" and should be enabled when appropriate. HTTP is "stateless" after all..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!