if ( msgContext.getFLOW() == MessageContext.IN_FLOW ) {
// get servlet context, request object
final ServletContext servletContext = (ServletContext) msgContext.getProperty(Constants.SERVLET_CONTEXT);
if(servletContext == null) {
System.out.println("servletcontext is null");
}
final HttpServletRequest request = (HttpServletRequest) msgContext.getProperty(Constants.HTTP_SERVLET_REQUEST);
if(request == null) {
System.out.println("httpservletrequest is null");
}
}
this puts out :
servletcontext is null
httpservletrequest is null
Since this code does do it for you, I'm really starting to wonder what might be wrong. Might it be due to my using WebLogic, incl. the <prefer-web-inf-classes> classloader setting ? Or might it have to do with the particular nightly build I'm using (from about 3 weeks ago) ?
As you can guess: any help, tips and advice is very welcome !
Heikki Doeleman
On 7/13/06, Carsten Ziegeler <
[EMAIL PROTECTED]> wrote:
Just to be sure, are you sure that your handler is only invoked for
incomming request? (I did this mistake and then run into an NPE as the
servlet request object is only available in the incomming flow, and I
tried to access it on the outgoing flow as well).
So this is my code which actually works for me:
if ( messageContext.getFLOW() == MessageContext.IN_FLOW ) {
// get servlet context, request object
final ServletContext servletContext = (ServletContext)
messageContext.getProperty (Constants.SERVLET_CONTEXT);
final HttpServletRequest request = (HttpServletRequest)
messageContext.getProperty(Constants.HTTP_SERVLET_REQUEST);
}
And they are both not null.
HTH
Carsten
heikki wrote:
> thanks for the tips, alas I'm still not getting the HttpServlet Request ..
>
> I tried, in the handler :
>
> 1. Deepal's tip :
>
> httpServletRequest = (HttpServletRequest) msgContext.getProperty(
> Constants.HTTP_SERVLET_REQUEST);
>
> 2. Robert's tip :
>
> httpServletRequest = (HttpServletRequest) msgContext.getOperationContext
> ().getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST );
>
> 3. those two combined :
>
> httpServletRequest = (HttpServletRequest) msgContext.getOperationContext
> ().getProperty(Constants.HTTP_SERVLET_REQUEST);
>
> In each case, I don't find the HttpServletContext, instead ending up with
> null.
>
> This being so, I do not fully understand this remark from Robert's post :
>
>
> "Its by design- you have to get the operation context from the outgoing
> MC and then get the incoming MC from that and look there for the servlet
> context and any other "incoming" info. "
>
> My handler is used to process incoming messages; how could I get things from
> outgoing MC at this stage ? Could you explain what is meant here?
>
> Does anyone have more advice on how I could obtain the HttpServletContext in
> a handler that operates on incoming messages? Surely this should be a quite
> easy task ..
>
--
Carsten Ziegeler - Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
