You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Tim Davidson <ti...@greenhatconsulting.com> on 2003/08/01 10:10:13 UTC
RE: Checking for invalidated session
But surely theres a better way?
Whould I be better off replacing "session.invalidate()" with "session = null"?
-----Original Message-----
From: Justin Ruthenbeck [mailto:justinr@nextengine.com]
Sent: Thursday, July 31, 2003 6:44 PM
To: Tomcat Users List
Subject: Re: Checking for invalidated session
At 08:31 AM 7/31/2003, you wrote:
>How can you check to see if a session has already been validated?
>i.e.
> if( !session.isInvalidated()) <-- what should go here?
>{
> session.invalidate();
>}
>
>to prevent the following exception:
>"org.apache.jasper.JasperException: invalidate: Session already invalidated"
If you don't want to just catch and ignore the JasperException, then use
something like this:
try
{
session.getAttributeNames();
}
catch (java.lang.IllegalStateException isse)
{
// Session is already invalid
}
justin
____________________________________
Justin Ruthenbeck
Software Engineer, NextEngine Inc.
justinr - AT - nextengine DOT com
Confidential
See http://www.nextengine.com/confidentiality.php
____________________________________
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Checking for invalidated session
Posted by Kwok Peng Tuck <pe...@makmal.net>.
How about:
if(session.getAttribute("myattrib")==null) {
}
Tim Davidson wrote:
>But surely theres a better way?
> Whould I be better off replacing "session.invalidate()" with "session = null"?
>
>-----Original Message-----
>From: Justin Ruthenbeck [mailto:justinr@nextengine.com]
>Sent: Thursday, July 31, 2003 6:44 PM
>To: Tomcat Users List
>Subject: Re: Checking for invalidated session
>
>
>At 08:31 AM 7/31/2003, you wrote:
>
>
>>How can you check to see if a session has already been validated?
>>i.e.
>> if( !session.isInvalidated()) <-- what should go here?
>>{
>> session.invalidate();
>>}
>>
>>to prevent the following exception:
>>"org.apache.jasper.JasperException: invalidate: Session already invalidated"
>>
>>
>
>If you don't want to just catch and ignore the JasperException, then use
>something like this:
>
>try
>{
> session.getAttributeNames();
>}
>catch (java.lang.IllegalStateException isse)
>{
> // Session is already invalid
>}
>
>justin
>
>____________________________________
>Justin Ruthenbeck
>Software Engineer, NextEngine Inc.
>justinr - AT - nextengine DOT com
>Confidential
> See http://www.nextengine.com/confidentiality.php
>____________________________________
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
>
>
>
Re: Checking for invalidated session
Posted by Kwok Peng Tuck <pe...@makmal.net>.
How about:
if(session.getAttribute("myattrib")==null) {
}
Tim Davidson wrote:
>But surely theres a better way?
> Whould I be better off replacing "session.invalidate()" with "session = null"?
>
>-----Original Message-----
>From: Justin Ruthenbeck [mailto:justinr@nextengine.com]
>Sent: Thursday, July 31, 2003 6:44 PM
>To: Tomcat Users List
>Subject: Re: Checking for invalidated session
>
>
>At 08:31 AM 7/31/2003, you wrote:
>
>
>>How can you check to see if a session has already been validated?
>>i.e.
>> if( !session.isInvalidated()) <-- what should go here?
>>{
>> session.invalidate();
>>}
>>
>>to prevent the following exception:
>>"org.apache.jasper.JasperException: invalidate: Session already invalidated"
>>
>>
>
>If you don't want to just catch and ignore the JasperException, then use
>something like this:
>
>try
>{
> session.getAttributeNames();
>}
>catch (java.lang.IllegalStateException isse)
>{
> // Session is already invalid
>}
>
>justin
>
>____________________________________
>Justin Ruthenbeck
>Software Engineer, NextEngine Inc.
>justinr - AT - nextengine DOT com
>Confidential
> See http://www.nextengine.com/confidentiality.php
>____________________________________
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
RE: Checking for invalidated session
Posted by Justin Ruthenbeck <ju...@nextengine.com>.
At 01:10 AM 8/1/2003, you wrote:
>But surely theres a better way?
> Whould I be better off replacing "session.invalidate()" with "session =
> null"?
No, you wouldn't be better off -- it won't work. :) There's no reason not
to like this solution, IMHO. If it makes your code look ugly, put it in a
static method and make it look like this:
if (SessionUtil.isInvalid(session))
justin
>At 08:31 AM 7/31/2003, you wrote:
> >How can you check to see if a session has already been validated?
> >i.e.
> > if( !session.isInvalidated()) <-- what should go here?
> >{
> > session.invalidate();
> >}
> >
> >to prevent the following exception:
> >"org.apache.jasper.JasperException: invalidate: Session already invalidated"
>
>If you don't want to just catch and ignore the JasperException, then use
>something like this:
>
>try
>{
> session.getAttributeNames();
>}
>catch (java.lang.IllegalStateException isse)
>{
> // Session is already invalid
>}
>
>justin
>
>____________________________________
>Justin Ruthenbeck
>Software Engineer, NextEngine Inc.
>justinr - AT - nextengine DOT com
>Confidential
> See http://www.nextengine.com/confidentiality.php
>____________________________________
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
____________________________________
Justin Ruthenbeck
Software Engineer, NextEngine Inc.
justinr - AT - nextengine DOT com
Confidential
See http://www.nextengine.com/confidentiality.php
____________________________________
RE: Checking for invalidated session
Posted by Murray <mp...@optusnet.com.au>.
I'm trying to ensure that a session is newly created when I reach my index
page. The logic is reversed from your question but I believe the principle
is the same inasmuchas I want to know whether or not a valid session exists.
if (! session.isNew() )
{
session.invalidate();
%>
<rsp:sendRedirect>
<rsp:encodeRedirectUrl>/scoutgroup/index.jsp</rsp:encodeRedirectUrl>
</rsp:sendRedirect>
<%
}
The redirect is to cause the page to be reloaded after the invalidate()
since JSP, by default, creates a new session when the page is loaded.
In the body of the page I had a line
<p>You are in session. The session id is <%=session.getId()%>.
which produces "The session id is null" prior to inserting the redirect.
After the redirect was inserted the html was not sent to the browser until a
valid session was established at which time each visit to or browser refresh
of the page produced a new session id.
Someone with more than three months of playing with this as a spare time
hobby feel free to critique the solution please.
Murray
-----Original Message-----
From: Tim Davidson [mailto:tim.davidson@greenhatconsulting.com]
Sent: Friday, 1 August 2003 18:10
To: Tomcat Users List
Subject: RE: Checking for invalidated session
But surely theres a better way?
Whould I be better off replacing "session.invalidate()" with "session =
null"?
-----Original Message-----
From: Justin Ruthenbeck [mailto:justinr@nextengine.com]
Sent: Thursday, July 31, 2003 6:44 PM
To: Tomcat Users List
Subject: Re: Checking for invalidated session
At 08:31 AM 7/31/2003, you wrote:
>How can you check to see if a session has already been validated?
>i.e.
> if( !session.isInvalidated()) <-- what should go here?
>{
> session.invalidate();
>}
>
>to prevent the following exception:
>"org.apache.jasper.JasperException: invalidate: Session already
invalidated"
If you don't want to just catch and ignore the JasperException, then use
something like this:
try
{
session.getAttributeNames();
}
catch (java.lang.IllegalStateException isse)
{
// Session is already invalid
}
justin
____________________________________
Justin Ruthenbeck
Software Engineer, NextEngine Inc.
justinr - AT - nextengine DOT com
Confidential
See http://www.nextengine.com/confidentiality.php
____________________________________
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Connecting Two PC using internet connection ??
Posted by Bikash Paul <bi...@yahoo.com>.
Hi,
I want to develop one software so that I can connect
two PC using internet connection means one is host and
another is remote.So that I can access remote PC's
Hard drive using internet connection.Can any one plz
give me some guideline how I can start.Eagerly waiting
for someone reply.
Thanks & Regards
Bikash
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
Connecting Two PC using internet connection ??
Posted by Bikash Paul <bi...@yahoo.com>.
Hi,
I want to develop one software so that I can connect
two PC using internet connection means one is host and
another is remote.So that I can access remote PC's
Hard drive using internet connection.Can any one plz
give me some guideline how I can start.Eagerly waiting
for someone reply.
Thanks & Regards
Bikash
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
RE: Checking for invalidated session
Posted by Murray <mp...@optusnet.com.au>.
I'm trying to ensure that a session is newly created when I reach my index
page. The logic is reversed from your question but I believe the principle
is the same inasmuchas I want to know whether or not a valid session exists.
if (! session.isNew() )
{
session.invalidate();
%>
<rsp:sendRedirect>
<rsp:encodeRedirectUrl>/scoutgroup/index.jsp</rsp:encodeRedirectUrl>
</rsp:sendRedirect>
<%
}
The redirect is to cause the page to be reloaded after the invalidate()
since JSP, by default, creates a new session when the page is loaded.
In the body of the page I had a line
<p>You are in session. The session id is <%=session.getId()%>.
which produces "The session id is null" prior to inserting the redirect.
After the redirect was inserted the html was not sent to the browser until a
valid session was established at which time each visit to or browser refresh
of the page produced a new session id.
Someone with more than three months of playing with this as a spare time
hobby feel free to critique the solution please.
Murray
-----Original Message-----
From: Tim Davidson [mailto:tim.davidson@greenhatconsulting.com]
Sent: Friday, 1 August 2003 18:10
To: Tomcat Users List
Subject: RE: Checking for invalidated session
But surely theres a better way?
Whould I be better off replacing "session.invalidate()" with "session =
null"?
-----Original Message-----
From: Justin Ruthenbeck [mailto:justinr@nextengine.com]
Sent: Thursday, July 31, 2003 6:44 PM
To: Tomcat Users List
Subject: Re: Checking for invalidated session
At 08:31 AM 7/31/2003, you wrote:
>How can you check to see if a session has already been validated?
>i.e.
> if( !session.isInvalidated()) <-- what should go here?
>{
> session.invalidate();
>}
>
>to prevent the following exception:
>"org.apache.jasper.JasperException: invalidate: Session already
invalidated"
If you don't want to just catch and ignore the JasperException, then use
something like this:
try
{
session.getAttributeNames();
}
catch (java.lang.IllegalStateException isse)
{
// Session is already invalid
}
justin
____________________________________
Justin Ruthenbeck
Software Engineer, NextEngine Inc.
justinr - AT - nextengine DOT com
Confidential
See http://www.nextengine.com/confidentiality.php
____________________________________
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
RE: Checking for invalidated session
Posted by Justin Ruthenbeck <ju...@nextengine.com>.
At 01:10 AM 8/1/2003, you wrote:
>But surely theres a better way?
> Whould I be better off replacing "session.invalidate()" with "session =
> null"?
No, you wouldn't be better off -- it won't work. :) There's no reason not
to like this solution, IMHO. If it makes your code look ugly, put it in a
static method and make it look like this:
if (SessionUtil.isInvalid(session))
justin
>At 08:31 AM 7/31/2003, you wrote:
> >How can you check to see if a session has already been validated?
> >i.e.
> > if( !session.isInvalidated()) <-- what should go here?
> >{
> > session.invalidate();
> >}
> >
> >to prevent the following exception:
> >"org.apache.jasper.JasperException: invalidate: Session already invalidated"
>
>If you don't want to just catch and ignore the JasperException, then use
>something like this:
>
>try
>{
> session.getAttributeNames();
>}
>catch (java.lang.IllegalStateException isse)
>{
> // Session is already invalid
>}
>
>justin
>
>____________________________________
>Justin Ruthenbeck
>Software Engineer, NextEngine Inc.
>justinr - AT - nextengine DOT com
>Confidential
> See http://www.nextengine.com/confidentiality.php
>____________________________________
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
____________________________________
Justin Ruthenbeck
Software Engineer, NextEngine Inc.
justinr - AT - nextengine DOT com
Confidential
See http://www.nextengine.com/confidentiality.php
____________________________________
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org