GeeCON Prague 2014*
The moose likes JSP and the fly likes Session tracking with model 1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "Session tracking with model 1" Watch "Session tracking with model 1" New topic
Author

Session tracking with model 1

Roger Graff
Ranch Hand

Joined: May 29, 2001
Posts: 112
I've developed several model 2/struts based applications, but not a model 1 based app.
When using a model 1 architecture, is the session id sent back to the client implicitly (via a cookie), or do I have to handle that programmatically?
Thanks,
Graff
Roger Graff
Ranch Hand

Joined: May 29, 2001
Posts: 112
I found the answer I was looking for in the book "Core Servlets & JSP" by Marty Hall. It states that by using the HttpSession class, session management/cookies are taken care of behind the scenes. In other words, it's done for you regardless if one uses a Model 1 or Model 2 approach.
-Graff
Roger Graff
Ranch Hand

Joined: May 29, 2001
Posts: 112
Okay, apparently session tracking does not work with Model 1.
My application has a JSP that creates a user object, stores it in the session, then displays a list of hyperlinks to other JSPs. When the user clicks on a hyperlink, a new JSP is called and a different session is created.
In a nutshell, a session object is created for each entry point into the application.
Using model 1, many sessions are created since there are many entry points into the application.
Using model 2, only one session is created since there is only 1 entry point into the application.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12792
    
    5
There is no inherent reason for session tracking not to work in model 1 or 2. Note that sessions are only shared within a servlet context == web application. If all of your jsp and servlets are in the same web application they should be able to share a session.
Bill
Roger Graff
Ranch Hand

Joined: May 29, 2001
Posts: 112
Originally posted by William Brogden:
There is no inherent reason for session tracking not to work in model 1 or 2. Note that sessions are only shared within a servlet context == web application. If all of your jsp and servlets are in the same web application they should be able to share a session.
Bill

I guess that's good news, but that's makes my bug even more odd. In the process of debugging, I displayed the jSessionID of each JSP and they are different.
Did I mention that when each hyperlink is clicked, a new browser is spawned? Perhaps some URL rewriting is in order....
Roger Graff
Ranch Hand

Joined: May 29, 2001
Posts: 112
Originally posted by Roger Graff:
[QB]Okay, apparently session tracking does not work with Model 1.

As usual, Bill is correct. Shame on me for jumping to conclusions!
My situation is unique and may require some manual cookie manipulation.
 
GeeCON Prague 2014
 
subject: Session tracking with model 1