aspose file tools*
The moose likes Servlets and the fly likes Difference Between JSP and Servlet Session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Difference Between JSP and Servlet Session" Watch "Difference Between JSP and Servlet Session" New topic
Author

Difference Between JSP and Servlet Session

Jimi Parekh
Greenhorn

Joined: Jul 30, 2006
Posts: 7
Hi,
Is there any difference between JSP and Servlet Sessions?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42944
    
  68
Not really, especially as JSPs are generally implemented as servlets. One difference is that JSP by default creates a session, while servlets do not.
ak pillai
author
Ranch Hand

Joined: Feb 11, 2006
Posts: 288
Yes as ulf said by deafault no session is created but you can create a session by


<%@ page session="true">


java j2ee job interview questions with answers | Learn the core concepts and the key areas
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by ak pillai:
Yes as ulf said by deafault no session is created but you can create a session by


<%@ page session="true">


You've got it backwards.
By default, JSPs create a session for you.
If you don't want your JSP to create a session, you have to use
<%@ page session="false">


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

If the application server creates an HttpSession for a user, that HttpSession is the same session used by every JSP and Servlet that user accesses. If you stuff some great data in the HttpSession in a Servlet, the client will be able to yank that data out of the HttpSession in any JSP or other Servlet in the application. Well, until their session times out, that is.

Here's more info on HttpSession objects:

http://www.technicalfacilitation.com/get.php?link=sessions

Regards,
[ August 27, 2006: Message edited by: Bear Bibeault ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference Between JSP and Servlet Session