Custom JSP taglib provides the reusable actions with sessions. Body tag IfNotDef redirects to the given URL in case of user's session does not contain the object with the specified name. It is a standard pattern for JSP programming. You may save some object in the session as an indicator of user's authorization for example. And all your JSP pages may have this tag at the beginning. As soon as the session does not exist or your "indicator" is not there IfNotDef tag redirects your visitor to some start page. Body tag IfSessionExpired executes own body if the request specified an old (expired) session ID (in other words current session has been expired).
For example:
1. Your login (start) page (servlet) saves id 'A' in user's session. E.g.:
session.setAttribute("A", new Object());
2. Your JSP pages looks so:
If URL starts with http request will be redirected to that site, otherwise tag assumes a local resource and forwards request.
You can use this tag as a body tag. Body will be executed if session
does not contain the specified attribute:
Tags are:
IfNotDef
Body tag checks session and executes own body or redirects to the specified URL if the given id is not in the session. Parameters are:
1) id Object ID (attribute name)
2) redirect Optional parameter. Describes an URL for the redirection/forwarding
IfSessionExpired
Body tag executes own body if session expired. Parameters are: none
for downloading:
Library: ifnotdef.jar Description: taglib.tld
See also Coldtags suite - the largest collection of custom JSP tags.