• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Session tracking with model 1

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Politics is a circus designed to distract you from what is really going on. So is this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic