You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Gary Young <yg...@yahoo.com> on 2000/03/01 17:41:26 UTC

HttpSession.isNew() Bug?

It seems isNew() always return true in Tomcat 3.1.
I have tested the function using both JSP and servlet.
Here is a JSP file:
<HTML>
<HEAD>
	<TITLE>JSP session page</TITLE>
</HEAD>
<BODY>
<%
	HttpSession ses=request.getSession(true);
	if(ses.isNew()) {
%>
<%=ses.getId()%>
<%	}
%>
</BODY>
</HTML>

The file always outputs the session's ID when it is
run
in Tomcat. However, if the application server is IBM
WebSphere(2.03 on Linux, and 3.02 on Solaris), it
ouputs the ID only at the first time.

Why does the function always return true? Is it a bug?

__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com

Re: HttpSession.isNew() Bug?

Posted by Gary Yang <yg...@yahoo.com>.
I believe here is a bug.

To fix it, add a line to the end of funciont
org.tomcat.session.StandardSession.access():
this.isNew = false;

i.e. replace file
src/share/org/apache/tomcat/session/StandardSession.java's line 339-349
from

    /**
     * Update the accessed time information for this session.  This
method
     * should be called by the context when a request comes in for a
particular
     * session, even if the application does not reference it.
     */
    public void access() {

        this.lastAccessedTime = this.thisAccessedTime;
        this.thisAccessedTime = System.currentTimeMillis();

    }

to:
   /**
     * Update the accessed time information for this session.  This
method
     * should be called by the context when a request comes in for a
particular
     * session, even if the application does not reference it.
     */
    public void access() {

        this.lastAccessedTime = this.thisAccessedTime;
        this.thisAccessedTime = System.currentTimeMillis();
        this.isNew = false;    // ************this line should be added

    }




Gary Young wrote:

> It seems isNew() always return true in Tomcat 3.1.
> I have tested the function using both JSP and servlet.
> Here is a JSP file:
> <HTML>
> <HEAD>
>         <TITLE>JSP session page</TITLE>
> </HEAD>
> <BODY>
> <%
>         HttpSession ses=request.getSession(true);
>         if(ses.isNew()) {
> %>
> <%=ses.getId()%>
> <%      }
> %>
> </BODY>
> </HTML>
>
> The file always outputs the session's ID when it is
> run
> in Tomcat. However, if the application server is IBM
> WebSphere(2.03 on Linux, and 3.02 on Solaris), it
> ouputs the ID only at the first time.
>
> Why does the function always return true? Is it a bug?
>
> __________________________________________________
> Do You Yahoo!?
> Talk to your friends online with Yahoo! Messenger.
> http://im.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com

RE: HttpSession.isNew() Bug?

Posted by Kevin Jones <ke...@develop.com>.
Sorry costin  - I was being a complete idiot.

I was doing some testing and I'd disabled cookies for my 'local zone' (I'm
using IE5) - sessions are working OK, and I see 'access' being called,

Kevin Jones
DevelopMentor

> -----Original Message-----
> From: costin@eng.sun.com [mailto:costin@eng.sun.com]
> Sent: 02 March 2000 16:54
> To: tomcat-dev@jakarta.apache.org
> Cc: ygary2@yahoo.com
> Subject: RE: HttpSession.isNew() Bug?
>
>
>
> > I see this fix in the latest drop of Tomcat, but it doesn't
> work for me. In
> > fact I never see the 'access' method called. So sessions still
> don't work
> > for me!
> >
>
> accessed() is called by SessionInterceptor if a sessionId is detected and
> a session is found for that id.
> I did a test and it worked fine for me, can you give more details ?
>
> Costin
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


RE: HttpSession.isNew() Bug?

Posted by co...@eng.sun.com.
> I see this fix in the latest drop of Tomcat, but it doesn't work for me. In
> fact I never see the 'access' method called. So sessions still don't work
> for me!
> 

accessed() is called by SessionInterceptor if a sessionId is detected and 
a session is found for that id. 
I did a test and it worked fine for me, can you give more details ? 

Costin


RE: HttpSession.isNew() Bug?

Posted by Kevin Jones <ke...@develop.com>.
I see this fix in the latest drop of Tomcat, but it doesn't work for me. In
fact I never see the 'access' method called. So sessions still don't work
for me!

Kevin Jones
DevelopMentor

> -----Original Message-----
> From: gyang [mailto:gyang]On Behalf Of Gary Yang
> Sent: 01 March 2000 20:18
> To: tomcat-dev@jakarta.apache.org
> Subject: Re: HttpSession.isNew() Bug?
>
>
> I believe here is a bug.
>
> To fix it, add a line to the end of funciont
> org.tomcat.session.StandardSession.access():
> this.isNew = false;
>
> i.e. replace file
> src/share/org/apache/tomcat/session/StandardSession.java's line 339-349
> from
>
>     /**
>      * Update the accessed time information for this session.  This
> method
>      * should be called by the context when a request comes in for a
> particular
>      * session, even if the application does not reference it.
>      */
>     public void access() {
>
>         this.lastAccessedTime = this.thisAccessedTime;
>         this.thisAccessedTime = System.currentTimeMillis();
>
>     }
>
> to:
>    /**
>      * Update the accessed time information for this session.  This
> method
>      * should be called by the context when a request comes in for a
> particular
>      * session, even if the application does not reference it.
>      */
>     public void access() {
>
>         this.lastAccessedTime = this.thisAccessedTime;
>         this.thisAccessedTime = System.currentTimeMillis();
>         this.isNew = false;    // ************this line should be added
>
>     }
>
>
>
>
> Gary Young wrote:
>
> > It seems isNew() always return true in Tomcat 3.1.
> > I have tested the function using both JSP and servlet.
> > Here is a JSP file:
> > <HTML>
> > <HEAD>
> >         <TITLE>JSP session page</TITLE>
> > </HEAD>
> > <BODY>
> > <%
> >         HttpSession ses=request.getSession(true);
> >         if(ses.isNew()) {
> > %>
> > <%=ses.getId()%>
> > <%      }
> > %>
> > </BODY>
> > </HTML>
> >
> > The file always outputs the session's ID when it is
> > run
> > in Tomcat. However, if the application server is IBM
> > WebSphere(2.03 on Linux, and 3.02 on Solaris), it
> > ouputs the ID only at the first time.
> >
> > Why does the function always return true? Is it a bug?
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Talk to your friends online with Yahoo! Messenger.
> > http://im.yahoo.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: HttpSession.isNew() Bug?

Posted by Gary Yang <yg...@yahoo.com>.
I believe here is a bug.

To fix it, add a line to the end of funciont
org.tomcat.session.StandardSession.access():
this.isNew = false;

i.e. replace file
src/share/org/apache/tomcat/session/StandardSession.java's line 339-349
from

    /**
     * Update the accessed time information for this session.  This
method
     * should be called by the context when a request comes in for a
particular
     * session, even if the application does not reference it.
     */
    public void access() {

        this.lastAccessedTime = this.thisAccessedTime;
        this.thisAccessedTime = System.currentTimeMillis();

    }

to:
   /**
     * Update the accessed time information for this session.  This
method
     * should be called by the context when a request comes in for a
particular
     * session, even if the application does not reference it.
     */
    public void access() {

        this.lastAccessedTime = this.thisAccessedTime;
        this.thisAccessedTime = System.currentTimeMillis();
        this.isNew = false;    // ************this line should be added

    }




Gary Young wrote:

> It seems isNew() always return true in Tomcat 3.1.
> I have tested the function using both JSP and servlet.
> Here is a JSP file:
> <HTML>
> <HEAD>
>         <TITLE>JSP session page</TITLE>
> </HEAD>
> <BODY>
> <%
>         HttpSession ses=request.getSession(true);
>         if(ses.isNew()) {
> %>
> <%=ses.getId()%>
> <%      }
> %>
> </BODY>
> </HTML>
>
> The file always outputs the session's ID when it is
> run
> in Tomcat. However, if the application server is IBM
> WebSphere(2.03 on Linux, and 3.02 on Solaris), it
> ouputs the ID only at the first time.
>
> Why does the function always return true? Is it a bug?
>
> __________________________________________________
> Do You Yahoo!?
> Talk to your friends online with Yahoo! Messenger.
> http://im.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org