Sessions administration taglib ver. 1.4

    Custom JSP taglib. You can use this taglib with Sessions admin listener from JSOS. Listener collects all the sessions in the servlet context (application scope for JSP). So your JSP application may have access to users sessions. You can implement for example some statistical or administrative tasks with the help of this taglib.

How to use it:

At the first hand you have to install filter (listener) for sessions administration. See Sessions administration in JSOS package.

After that you may use an appropriate custom tag in your JSP page. For example, tag forEachSession lets you iterate over exiting sessions:
 


<%@ taglib uri="taglib.tld" prefix="s" %>

<s:forEachSession>

  <br>Session Id is <%=currentSession.getId()%>

</s:forEachSession>

Here we used nested page scope variable currentSession (type is javax.servlet.http.HttpSession). Through this variable you can access to the session data.

Instead of HttpSession API you can use custom tag getAttribute. This tag is similar to the HttpSession.getAttribute() call, but catch exceptions raised by the invalidated sessions. E.g.:
 


<s:getAttribute name="login" session="<%=currentSession%>">not available</s:getAttribute>

Tags are:

forEachSession

Body tag, iterates over existing sessions. Parameters are:

1) id Optional parameter. Describes a name for the nested page scope variable with the current session. (type is javax.servlet.http.HttpSession). Default value is currentSession.

getSessionsCount

counts sessions. Parameters are:

1) id Optional parameters. Describes a name for the page scope variable (type is java.lang.Integer). With this parameter tag saves data in that variable. Without it (default behavior) tag just prints data.

getAttribute

Body tag for protected access to attributes of sessions. Tag's body describes a default value (if the requested session itself or the named attribute is unavailable). Parameters are:

1) name describes a name for attribute
2) sessionId Optional parameter. Describes an ID for the requested session
3) session Optional parameter. Describes a requested session

setAttribute

Body tag for protected setting of attributes for sessions. Tag's body describes a value. Parameters are:

1) name describes a name for attribute
2) sessionId Optional parameter. Describes an ID for the requested session
3) session Optional parameter. Describes a requested session

invalidate

Body tag for protected invalidation of sessions. Parameters are:

1) sessionId Optional parameter. Describes an ID for the requested session
2) session Optional parameter. Describes a requested session

getSize

Tag lets you calculate the size (in bytes) for your sessions. Parameters are:

1) id Optional parameters. Describes a name for the page scope variable (type is java.lang.Integer). With this parameter tag saves data in that variable. Without it (default behavior) tag just prints data.
2) sessionId Optional parameter. Describes an ID for the requested session
3) session Optional parameter. Describes a requested session

for downloading:

Library: sessadm.jar    Description: taglib.tld

© Coldbeans      Comments?

See also Coldtags suite - the largest collection of custom JSP tags.

     

Also in JSOS: