• Post Reply Bookmark Topic Watch Topic
  • New Topic

Controlling Session Time Out  RSS feed

 
Steve Dyke
Ranch Hand
Posts: 1739
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to documentation I should be able to set the session timeout value in the Deployment Descriptor.

However, I have set it to a value of 3 minutes for testing some code I need to run at the timeout event but the session time out does not occur.

What constitutes inactivity? I have some javascript timers firing, is this considered activity?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. The server has no idea what the JavaScript in the browser is doing.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you trying to use the session timeout as a timer? If so, that's not what it's intended for and not what you should be using it for.

What is it that you are trying to accomplish?
 
Steve Dyke
Ranch Hand
Posts: 1739
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:

What is it that you are trying to accomplish?


Something is causing a NullPointerException at code like the following(eraticly):



I have a redirection filter set up for session time out so I would figure it would handle it. Not sure what is causing the session attributes to be dropped.

I just was trying to force session time out for testing.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The absence of the named scoped variable in the session will not cause a null pointer exception in that line.

Moved to the Servlets forum as this has nothing to do with JavaScript.
 
Steve Dyke
Ranch Hand
Posts: 1739
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:The absence of the named scoped variable in the session will not cause a null pointer exception in that line.



I did not explain very good sorry. The exception occurs when trying to access properties of the user object that does not exist.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be checking for null before de-referencing.
 
Steve Dyke
Ranch Hand
Posts: 1739
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:You should be checking for null before de-referencing.


Is there a way to do this on a web application global scale instead of at the point of every instance?

Example I have the follow code 818 times:

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You already seemed to discovered filters.
 
Steve Dyke
Ranch Hand
Posts: 1739
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:You already seemed to discovered filters.


This is my filter code:



But I have yet to figure out where to place the following so it does not produce the time out condition when the app is first initialized since the object does not exist until initialization:

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What time out condition? The session timeout? Just set that to what you want it to be and forget about it. Aside from setting its duration, you don't need to be concerned with it.

Aside from setting cache control headers, which is evident, you haven't explained what else you are trying to accomplish with the filter.
 
Steve Dyke
Ranch Hand
Posts: 1739
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:What time out condition? The session timeout? Just set that to what you want it to be and forget about it. Aside from setting its duration, you don't need to be concerned with it.

Aside from setting cache control headers, which is evident, you haven't explained what else you are trying to accomplish with the filter.


Changing the statement:

But I have yet to figure out where to place the following so it does not produce the time out condition when the app is first initialized since the object does not exist until initialization:

To:

But I have yet to figure out where to place the following so it does not produce the 'TimedOutDisplayForm.jsp' when the app is first initialized since the object does not exist until initialization:


Originally I thought this filter was used to display the 'TimedOutDisplayForm.jsp' when I would stop the application server for re-deploys, etc.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve Dyke wrote:Originally I thought this filter was used to display the 'TimedOutDisplayForm.jsp' when I would stop the application server for re-deploys, etc.

Well, if the app isn't running, certainly any filter isn't going to run.

With regards to the rest, I'm still clueless as to what you are trying to accomplish. You keep going on about a "timeout" and it's not clear at all what that is all about. There is no timeout with which you need to be concerned or be trying to manipulate.

Are you trying to create your own security filter? What is it that you are actually trying to accomplish?
 
Steve Dyke
Ranch Hand
Posts: 1739
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:

Are you trying to create your own security filter? What is it that you are actually trying to accomplish?


Application starts, a user object is initialized and set as session attribute.

This attribute is referenced many places(818 times) in the application code as:



In my servlets I have try/catch blocks:



On occasion I get this system output:



The reason is because the user object no longer exists. I have yet to figure out what is causing this. But my desire is as soon as this condition is found to call the session invalidate() which will display the Session has Expired web page.

But I rather not have to write this code 818 times. Or do it for every one of the many other objects set to session attributes.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a named reference was IN the session at one point but later was not there, we must conclude that either:

1. the session was invalidated in your code somehow
-OR-
2. your code removed the named reference

Are you paying close attention to the difference between the operation of:

getSession() and getSession( boolean flag )

Bill
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's impossible to set a scoped variable in the session when the application starts. A session can only be referenced when a request is made. So I'm still not sure what this is all about.

When is the user scoped variable actually created and why? It can't be at application startup as you described.

Once again, you have explained in detail what you are doing at the micro level, but you have yet to described what all of this is trying to accomplish in the first place.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!