You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jerry Malcolm <te...@malcolms.com> on 2024/05/23 16:01:58 UTC
Security Constraints and Session Timeout
I have some servlets that I can't put security constraints on at the
web.xml level. However, deep down in the code there are some places
that I need a user to be logged in. My overall UI ensures this all
works by having certain JSPs with constraints that force the user to log
in before getting to the servlet. But if the user spends too much time
interacting with the servlet and not reloading one of the pages that
require a login, the session will timeout, and the user is now buried in
one of the servlets, and I've lost the session/userprincipal. It
appears that interacting with a servlet that has no constraints does not
reset the session timer. Is that correct, or am I seeing it wrong? I
know the easy answer would be to add a constraint requiring login to
access the servlet. But with the current design, that's not going to
work. Is there something I can do in the servlet and/or servlet config
in web.xml to force servlet access to keep resetting the session timer
so it won't expire without having to put role constraints directly on
the servlet?
Thx
Jerry
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Security Constraints and Session Timeout
Posted by Mark Thomas <ma...@apache.org>.
On 23/05/2024 17:01, Jerry Malcolm wrote:
> I have some servlets that I can't put security constraints on at the
> web.xml level. However, deep down in the code there are some places
> that I need a user to be logged in. My overall UI ensures this all
> works by having certain JSPs with constraints that force the user to log
> in before getting to the servlet. But if the user spends too much time
> interacting with the servlet and not reloading one of the pages that
> require a login, the session will timeout, and the user is now buried in
> one of the servlets, and I've lost the session/userprincipal. It
> appears that interacting with a servlet that has no constraints does not
> reset the session timer. Is that correct, or am I seeing it wrong? I
> know the easy answer would be to add a constraint requiring login to
> access the servlet. But with the current design, that's not going to
> work. Is there something I can do in the servlet and/or servlet config
> in web.xml to force servlet access to keep resetting the session timer
> so it won't expire without having to put role constraints directly on
> the servlet?
Just calling HttpServletRequest.getSession(false) from the Servlet
should be sufficient.
Note you can monitor the expiration time for sessions using the Manager
application. That might be helpful in testing.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org