You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Shade, Christopher" <Ch...@247media.com> on 2000/08/22 01:34:07 UTC

does a context get a new session?

I've seen a variety of session problems posted to the list and in the
archives.  But i'm not sure what's happening in my case.  I have an initial
JSP that puts a Long object into the session, then the user hits a hyperlink
to a servlet, which does stuff and forwards to another JSP.  So it's a JSP
to Servlet to JSP kind of model.  Is it possible that this movement across
contexts (from the /servlet context to the context i defined in the
server.xml for my JSPs) is affecting the session?  
Because when I go to the /servlet context, it creates a new session, so the
Long object isn't there.  But if I just go between JSPs (that are all in the
same directory) the session retains its state.  And the session retains its
state when I go from the servlet to a JSP using
getServletContext().getRequestDispatcher().forward().
I see this code in the InvokerServlet.init() but I don't understand if this
means the invoker gets a new context and session when it invokes a servlet.
 
    public void init() throws ServletException {
 ServletContextFacade facade =
     (ServletContextFacade)getServletContext();
        context = facade.getRealContext();
    }

Totally at a loss, and thanks for any advice,
...Christopher
 
  _____  

Christopher X. Shade 
Senior Software Engineer, 24/7 Mail 
Sun Certified Programmer for the JavaTM 2 Platform 

24/7 Media Inc. (NASDAQ: TFSM) 
717 17th Street, Suite 500 
Denver, CO  80202 
tel) 303.942.4653 
fax) 303.675.2389 
Company vision: To be the preeminent global provider of interactive
marketing solutions and services. 

http://www.247media.com <http://www.exactis.com/>  
 

Re: does a context get a new session?

Posted by William Brogden <wb...@bga.com>.

"Shade, Christopher" wrote:
> 
> I've seen a variety of session problems posted to the list and in the
> archives.  But i'm not sure what's happening in my case.  I have an initial
> JSP that puts a Long object into the session, then the user hits a hyperlink
> to a servlet, which does stuff and forwards to another JSP.  So it's a JSP
> to Servlet to JSP kind of model.  Is it possible that this movement across
> contexts (from the /servlet context to the context i defined in the
> server.xml for my JSPs) is affecting the session?
> Because when I go to the /servlet context, it creates a new session, so the
> Long object isn't there.  But if I just go between JSPs (that are all in the
> same directory) the session retains its state.  And the session retains its
> state when I go from the servlet to a JSP using
> getServletContext().getRequestDispatcher().forward().


I bet that if you examine the cookie being written,it is restricted to
the
path the JSP pages are on.

-- 
WBB - wbrogden@bga.com  Chief Scientist, LANWrights, Inc.
Java Programmer Certification information and mock exam
at  http://www.lanw.com/java/javacert/