tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gould...@netscape.net
Subject Re: Problem with session tracking
Date Tue, 24 Apr 2001 15:30:43 GMT
I managed to get it working. Basically, what was happening is that Tomcat didn't think that
the servlet and the JSP page were part of the same application. I believe that what happens
is that you get different sessions for different apps running under Tomcat. The problem was
that I'd misconfigured the app in the web.xml file. I redid it like the following extract:

<web-app>

    <display-name>Hello, World Application</display-name>
    <description>
        Simple test servlet.
    </description>

    <servlet>
        <servlet-name>InterestToJsp</servlet-name>
        <servlet-class>com.cwb.interest.InterestToJsp</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>InterestToJsp</servlet-name>
        <url-pattern>/InterestToJsp</url-pattern>
    </servlet-mapping>

</web-app>

This seemed to fix the problem, though why my previous misconfiguration caused it to think
my servlet was part of a different app I'm not quite sure.

Hope this helps. If you need any more detail, get back to me, though I'm not going to be around
for long today...

Cheers,
Alan.


tomcat-user@jakarta.apache.org wrote:
>
> I´m having the same problem.
> I use a servlet to control my application and Jsp´s just to apresentation..
> 
> How did you resolve that?
> 
> []´s
> 
> Daniel A.
> 
> gouldina@netscape.net wrote:
> 
> > My understanding is that sendRedirect() goes back to the client to do the redirection
rather than doing it on the server which is obviously more efficient.
> > Have made some more progress and can now get a redirect to a servlet in the same
package and keep the same session so my guess is now that it's something to do with the way
that Tomcat thinks the web apps are partitioned - i.e. I don't think it thinks that it can/should
reuse the same session for the jsp page I was redirecting it to for some reason.
> >
> > tomcat-user@jakarta.apache.org wrote:
> > >
> > > Hmm.....
> > > I guess its because your forwarding the context wholesale. I'd guess the
> > > sesion is new within that given context, and because your effectively
> > > recreating the context when you forward in that manner, it still counts as
> > > new. I use sendRedirect  instead and this works fine - what do you loose my
> > > using sendRedirect rather than forwarding?
> > >
> > > sam
> > > ----- Original Message -----
> > > From: <gouldina@netscape.net>
> > > To: <tomcat-user@jakarta.apache.org>
> > > Sent: Tuesday, April 24, 2001 11:21 AM
> > > Subject: Re: Problem with session tracking
> > >
> > >
> > > > Sam wrote:
> > > >
> > > > >
> > > > > There is a difference between the way HttpSessions arew created and
> > > handled,
> > > > > and the Cookie objetc. The cookie object creates a persistant cookie
on
> > > the
> > > > > clients machine. The HttpSession is just a memory cookie, and as
such is
> > > > > non-persistant and doesn't sit on disk.
> > > >
> > > > Interesting. Would you expect to see the session cookie when you call
the
> > > getCookies() method then or not?
> > > >
> > > > Since my last mail, I've made some progress and can get isNew() to return
> > > false if I comment out the last few lines of the servlet method which
> > > forward to a jsp page:
> > > >
> > > > ServletContext servletContext = getServletConfig().getServletContext();
> > > > RequestDispatcher requestDispatcher =
> > > servletContext.getRequestDispatcher("/myapp/jsp/hello.jsp");
> > > > requestDispatcher.forward(request, response);
> > > >
> > > > Why would this screw up my session?
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > __________________________________________________________________
> > > > Get your own FREE, personal Netscape Webmail account today at
> > > http://webmail.netscape.com/
> > > >
> > >
> > >
> > __________________________________________________________________
> > Get your own FREE, personal Netscape Webmail account today at http://webmail.netscape.com/
> 
> 
__________________________________________________________________
Get your own FREE, personal Netscape Webmail account today at http://webmail.netscape.com/

Mime
View raw message