Forums Register Login

Controlling Session Time Out

+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
No. The server has no idea what the JavaScript in the browser is doing.
+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
You should be checking for null before de-referencing.
+Pie Number of slices to send: Send
 

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:

+Pie Number of slices to send: Send
You already seemed to discovered filters.
+Pie Number of slices to send: Send
 

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:

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
 

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?
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1081 times.
Similar Threads
session timeout
session timeouts
Telling who is logged onto my jsp application and occasionally logging their activities
Mock Question
Query Time out
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 12:01:41.