James Liao wrote:
6/14/05, Edmund Urbani <emu (AT) liland (DOT) orgwrote:
>
>>I'm trying to find out the browser issuing the request in my portlet.
>>Looks like the portlet API provides no way to access the "User-Agent"
>>HTTP header info. At least, I found none. Is there some way to access
>>the servlet request? or some jetspeed-2 specific (non-JSR168) way to
>>get this HTTP header?
>>
>>if all else fails, I'll probably have to solve this with javascript and
>>that would be plain ugly.
>>
>>cheers,
>>Edmund
>>
>>
>
>>
>Hi,
>You should try this in your portlet code.
>HttpServletRequest sss = (HttpServletRequest)((HttpServletRequestWrapper)
>request).getRequest();
>sss.getHeader("User-Agent");
>
>or you can import a jetspeed2 service named ServletContextProvider into your
>portlet, then you can get HttpServletRequest, HttpServletResponse and
>ServletContext from it.
>
>-James Liao
the first solution seems to work fine. i'm doing checks with
'instanceof' to be on the safe side here. so it's actually been bloated
to about this:
if (req instanceof HttpServletRequestWrapper) {
HttpServletRequestWrapper reqWrapper=(HttpServletRequestWrapper)req;
ServletRequest ();
if (servletReq instanceof HttpServletRequest) {
HttpServletRequest httpServletReq=(HttpServletRequest)servletReq;
String ("User-Agent");
}
}
that should do nicely. thanks a lot!
cheers,
Edmund
To unsubscribe, e-mail: jetspeed-user-unsubscribe (AT) portals (DOT) apache.org
For additional commands, e-mail: jetspeed-user-help (AT) portals (DOT) apache.org