I am trying to get the current request object within a class that is not a
servlet nor a
JSP page. I would like to create a static function where I can get the current Session,Request,or Response objects. Is there someway to do this by Thread.currentThread() or ServletContext? A simple example...
public class Current {
public static int UserID() {
HttpServletContext request = Current.Instance.Of.Executing.Servlet;
return (int)request.session.getAttribute("CurrentUserID");
}
}
So I could call...
int currentUserID = Current.UserID();
instead of doing a super long inline statement within my servlet or JSP code.
(int)session.getAttribute("CurrentUserID");
This is a very simplified version of what I am trying to accomplish as more complex versions would allow a object to be returned that may habe many getter methods.
[ February 17, 2004: Message edited by: Scot Meyer ]