You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Zhiyong Li <Zh...@ibiomatics.com> on 2002/02/13 16:08:00 UTC

session question for tomcat 4.0.1 and 4.0.2

I posted the following message a while ago and have not got any
response. So, I tried it on tomcat 4.0.2 release. However, I got the
same result. I would appreciate your help.

>2. I am trying to use isNew() method on session to detect whether a
>session is newly created or not. For example, 
>
>		HttpSession session = request.getSession();
>		
>		if (session.isNew()) {
>			// do something
>		}
>
>However, session.isNew() always returns "false". I tried several other
>combinations such as: request.getSession(true) and I got the same
>result.
>
>Are these two known problems or anything I am missing?
>

Zhiyong Li
Analytical Solutions, SAS Institute
(919) 653-2746
Zhiyong.Li@sas.com



--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: session question for tomcat 4.0.1 and 4.0.2

Posted by Charlie Toohey <ct...@pacbell.net>.
First, of all, the assumption is that you have not turned off session support 
using the JSP page directive, i.e. you do NOT have
<%@ page session="false">
The default is "true", so as long as you do not have this, you are fine.

Now, session.isNew() would continually return "false" if the following 
conditions were true:

1. the browser you are testing with is set to NOT accept cookies,

AND 

2. you are not encoding your URL's in which case Tomcat can not manage 
sessions using URL rewriting, e.g. you should be doing the following in your 
.jsp files :

<a href=<%=response.encodeURL("page1.jsp")%>>Page 1</a>


- Charlie


On Wednesday 13 February 2002 07:08 am, Zhiyong Li wrote:
> I posted the following message a while ago and have not got any
> response. So, I tried it on tomcat 4.0.2 release. However, I got the
> same result. I would appreciate your help.
>
> >2. I am trying to use isNew() method on session to detect whether a
> >session is newly created or not. For example,
> >
> >		HttpSession session = request.getSession();
> >
> >		if (session.isNew()) {
> >			// do something
> >		}
> >
> >However, session.isNew() always returns "false". I tried several other
> >combinations such as: request.getSession(true) and I got the same
> >result.
> >
> >Are these two known problems or anything I am missing?
>
> Zhiyong Li
> Analytical Solutions, SAS Institute
> (919) 653-2746
> Zhiyong.Li@sas.com

--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>