Wednesday, November 21, 2007

Who is using my system?



If you have a web application, based on Servlets/JSP (JEE), which sits behind the Apache/mod_jk, and you would like to track who is using your system, here is what to do:

1. In the Apache configuration (probably Vhost definition, as in my case), you will need:
        • JkMount /* NAME_OF_YOUR_WORKER
        • JkEnvVar REMOTE_USER "<NOTSET>"
The second entry will pass the information about user logged in on the Apache level down to your web application
2. In your application you can check who is using it, with credentials on the Apache level, with:
        • ${ REMOTE_USER } (JSP/EL)
        • request.getAttribute("REMOTE_USER") (Servlet or JSP/Scriptlets)
3. In your application you can also check who is using it, with credentials on the Tomcat level, with:
        • ${ pageContext.request.remoteUser } (JSP/EL)
        • request.getRemoteUser() (Servlet or JSP/Scriptlets)

That’s it.

Unless, your system is DSpace - where more problems will arise. You will need to, e.g.,
1. The register user is hidden in request.getAttribute("dspace.current.user"), and is of type org.dspace.eperson.EPerson
2. In order to get some human-readable description of this user you can call getEmail() method to get the email of the user.


No comments: