tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Wentzel <>
Subject RE: Help on application scope
Date Fri, 06 Jul 2001 18:42:59 GMT
> Dear all,
>     I used a java.util.HashMap for session invalidation in my 
> JSPs. It is
> declared as such in 2 jsps:
>            <jsp:useBean id="monitor" class="java.util.HashMap"
> scope="application" />
> (GalleryViewBottom.jsp
> and Logout.jsp)
>     Now the funny thing is when I issue a
>              monitor.put(request.getRemoteAddr(), session);
> (GalleryViewBottom.jsp)
>     And then try to access it from Logout.jsp the monitor has 
> no such key
> value. Isn't application scope mean its accessable from ANY 
> jsp page? I got
> the ideas for this code from Professional JSP (WROX, pg133 
> checklogin.jsp).

Another way to do this, and better in my opinion, would be to
write a GenericServlet which has a static HashMap member which
gets initialized in init() method and has a static get and
put method.  Configure the servlet as a load-on-startup servlet
and you're ready to go.  Just import the class and do


This will remove lines of code from the servlet generated from your
jsp(autogenerated by the useBean tag).

You could also include remove() and clear() methods.

Michael Wentzel
Software Developer
Software As We Think -

View raw message