03. juni 2009 - 11:07Der er
6 kommentarer og 1 løsning
How to specify a error page for session-timeout in web.xml?
Hello!
I have tried to find how to set up that a certain page should be shown if there is a session-time out in my web.xml. I guess a session-timeout got a certain error-code. Then I guess some of the follwing should redirect the user to a certain page.
Denne side indeholder artikler med forskellige perspektiver på Identity & Access Management i private og offentlige organisationer. Artiklerne behandler aktuelle IAM-emner og leveres af producenter, rådgivere og implementeringspartnere.
Actually there is no log in page, jsu som stuff saved in the session. If the user is inactive to long we would like the session to expire. If the user then become active again, then it would be great with a page telling him that the session has expired.
What can I say, really elegant solution! Time after time I just "state" you are playing in such an other division then me, the "eksperts"! It took some time for me to understand your solution, but now I think I get it!
Btw I have never used Filters before and I do have to say that I have not used this iteration either over a list: for(Cookie c : allc) ...really inspiring!
Before I saw your solution I just tested if(ses.isNew()) in the ActionClass, and then told Struts to forward to an error page.
But correct me if I'm wrong when I now say (if I understand this correct) that ses.isNew() is actually not enough, since I also found this in the doc:
"Returns true if the client does not yet know about the session or if the client chooses not to join the session. For example, if the server used only cookie-based sessions, and the client had disabled the use of cookies, then a session would be new on each request."
...Must remember to do some more reading before using ...
Once again most thankful for a such a nice solution! Feel stupid I just put 30 points to this, but please give a "svar" so I can give some reward at least!
The new for loop is just the Java way of doing foreach that was introduced in Java 1.5. Nothing special about that. I could just as well have used an oldfashioned for loop.
The logic in my code is based on: - isNew() returns true => the server does not have a session - cookie present => a valid session existed earlier
It is somewhat a hack, but given the rather unusual requirements, then I think it has to be that way.
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.