RE: Checking for invalidated session

2003-08-01 Thread Tim Davidson
But surely theres a better way?
 Whould I be better off replacing session.invalidate() with session = null?

-Original Message-
From: Justin Ruthenbeck [mailto:[EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Checking for invalidated session

2003-08-01 Thread Kwok Peng Tuck
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:[EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Checking for invalidated session

2003-08-01 Thread Murray
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
  pYou 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:[EMAIL PROTECTED]
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:[EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Checking for invalidated session

2003-08-01 Thread Tim Davidson
thanks.
the other option which I dont like was:
try
{
 session.invalidate();
}
catch (Throwable t)
{
 // Session is already invalid
}

-Original Message-
From: Murray [mailto:[EMAIL PROTECTED]
Sent: Friday, August 01, 2003 2:14 PM
To: Tomcat Users List
Subject: RE: Checking for invalidated session


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
  pYou 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:[EMAIL PROTECTED]
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:[EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Checking for invalidated session

2003-08-01 Thread Justin Ruthenbeck
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Justin Ruthenbeck
Software Engineer, NextEngine Inc.
justinr - AT - nextengine DOT com
Confidential
   See http://www.nextengine.com/confidentiality.php

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Checking for invalidated session

2003-07-31 Thread Moraes, Fabio

i guess this will work fine ...

session = request.getSession( false );

if( session.isNew( ) )
{
out.println( new session );
}

someone let me know if i'm wrong.

hugs,

---
 Fabio Moraes
 [EMAIL PROTECTED]
 System Engineer
 Work Force Management System
 +55 21 3088 9548


-Original Message-
From: Tim Davidson [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 31, 2003 12:32
To: [EMAIL PROTECTED]
Subject: Checking for invalidated session


Hi,

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

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Checking for invalidated session

2003-07-31 Thread Moraes, Fabio

sorry.

session = request.getSession( false );

if( session != null )
{
session.invalidate();
}

---
 Fabio Moraes
 [EMAIL PROTECTED]
 System Engineer
 Work Force Management System
 +55 21 3088 9548


-Original Message-
From: Moraes, Fabio [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 31, 2003 12:37
To: 'Tomcat Users List'
Subject: RE: Checking for invalidated session
Importance: High



i guess this will work fine ...

session = request.getSession( false );

if( session.isNew( ) )
{
out.println( new session );
}

someone let me know if i'm wrong.

hugs,

---
 Fabio Moraes
 [EMAIL PROTECTED]
 System Engineer
 Work Force Management System
 +55 21 3088 9548


-Original Message-
From: Tim Davidson [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 31, 2003 12:32
To: [EMAIL PROTECTED]
Subject: Checking for invalidated session


Hi,

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

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Checking for invalidated session

2003-07-31 Thread Tim Davidson
No that wont work, because if the session was null it would throw a 
nullpointerexception not a servletException with the session is already invalidated 

-Original Message-
From: Moraes, Fabio [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 31, 2003 4:39 PM
To: 'Tomcat Users List'
Subject: RE: Checking for invalidated session
Importance: High



sorry.

session = request.getSession( false );

if( session != null )
{
session.invalidate();
}

---
 Fabio Moraes
 [EMAIL PROTECTED]
 System Engineer
 Work Force Management System
 +55 21 3088 9548


-Original Message-
From: Moraes, Fabio [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 31, 2003 12:37
To: 'Tomcat Users List'
Subject: RE: Checking for invalidated session
Importance: High



i guess this will work fine ...

session = request.getSession( false );

if( session.isNew( ) )
{
out.println( new session );
}

someone let me know if i'm wrong.

hugs,

---
 Fabio Moraes
 [EMAIL PROTECTED]
 System Engineer
 Work Force Management System
 +55 21 3088 9548


-Original Message-
From: Tim Davidson [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 31, 2003 12:32
To: [EMAIL PROTECTED]
Subject: Checking for invalidated session


Hi,

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

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Checking for invalidated session

2003-07-31 Thread Justin Ruthenbeck
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]