Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

Session persistence across JSP/HTML/servlet

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Session persistence across JSP/HTML/servlet

    I think perhaps I misunderstand the concept of session persistence. In general, the idea is to a request.getSession(true) to get a new session (if it doesn't exist), and a request.getSession(false) to get the existing session (or null if it doesn't exist). Finally, session.invalidate() gets rid of the session. (Am I right so far?) Okay, given that understanding, and I thought then that it was up to the HTTP server to determine and hold the persistence of that connection. How? I don't know, it's magic. And I hate magic. For example, how can the HTTP server distinguish between two different instances of a browser on one PC? They have the same source IP address, so what tells them apart? So I figure it's something in the HTTP protocol that communicates between the server and the browser, and I continue on my merry way. But it's still bugging me, so I decide I better check. So I do this: I run a JSP, which creates a session using getSession(true) - this works, because I print out the ID. The JSP has a hyperlink to an HTML page. The HTML page has a form/button that POSTS to a servlet. The servlet does a getSession(false). Silly me, I expected the servlet to get the same session that I created in the JSP. But noooooo... I get null. Somewhere the connection got broken and I lost my session. So which part am I miunderstanding? Is the session not valid across different web components (JSP, HTML, servlet)? Is the session only valid on a single servlet (that is, does everything have to go through a master servlet, which figures out the data flow)? Did I forget to set a switch in my HTTP server or in WebSphere? I'm using WAS3.0 on V4R4, if that helps. Joe

  • #2
    Session persistence across JSP/HTML/servlet

    Joe,

    http://www.ibm.com/developer

    has a nice on-line tutorial on "Building Servlets with Session Tracking". You might want to check it out.

    Also from:

    Building AS/400 Applications for IBM

    WebSphere Standard Edition 2.0

    The javax.servlet.http.HttpSession interface is implemented by WebSphere to provide session support. Under the covers HttpSession information is maintained SIZE="2">either by using cookies or by URL rewriting described previously. The FACE="Helvetica" SIZE="2">administration GUI can be used to enable session support using URL rewriting FACE="Helvetica" SIZE="2">cookies as shown in Figure 137 on page 150. If both options are checked,cookies are used if the browser accepts them. Otherwise, URL rewriting is used.

    Nathan.

    Comment

    Working...
    X