Vic Simkus wrote:
>> HttpServletRequest has a getContextPath() that you can use.
>>   
> <snip>
> 
> Hi, Scott
> 
> I don't have access to anything "web related" within the class/method.  
> Does Resin provide any way of extracting that sort of information (shot 
> in a dark here) based on the current thread?
> 
> Thanks

This is a hack, but what we do is create a ThreadLocal with the current 
request object.  Something like this:

public abstract class ThreadRequest {

     private static ThreadLocal requestHolder = new ThreadLocal();
     /**
      * Sets the current thread's request.
      */
     public static void setRequest(HttpServletRequest request) {
         requestHolder.set(request);
     }

     /**
      * Gets the current thread's request.
      */
     public static HttpServletRequest getRequest() {
         return (HttpServletRequest) requestHolder.get();
     }
}

Then you need a filter that sets this and clears it from the thread.

ThreadRequest.setRequest(request);
try {
     // Now hand it off to everything else.
     chain.doFilter(proxiedRequest, response);
} finally {
     ThreadRequest.setRequest(null);
}


This gives you static access to the current request on this thread.

-- 
Serge Knystautas
Lokitech >> software . strategy . design >> http://www.lokitech.com
p. 301.656.5501
e. [EMAIL PROTECTED]


_______________________________________________
resin-interest mailing list
resin-interest@caucho.com
http://maillist.caucho.com/mailman/listinfo/resin-interest

Reply via email to