Re: How to get hold of current servlet context and session in axis 1.2
it worked ! Thanks Shantanu On 8/17/05, Javier Gonzalez <[EMAIL PROTECTED]> wrote: If I see it right, you are missing a step.This instruction:(HttpSession)messageContext.getProperty( HTTPConstants.MC_HTTP_SERVLETREQUEST);will return a HttpServletRequest object, not a HttpSessionObject.You need to do:HttpSession session =((HttpServletRequest)messageContext.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST )).getSession();On 8/17/05, shantanu chawla <[EMAIL PROTECTED]> wrote:> my webservice running is axis1.2RC3 needs to access current servlet session > and servletContext. I believe axis is running as a servlet so I can get hold> of the session and servlet context.>> I am using this code: MessageContext messageContext = > MessageContext.getCurrentContext();>> HttpServlet servlet => (HttpServlet)messageContext.getProperty(HTTPConstants.MC_HTTP_SERVLET);> ServletContext servletContext => (ServletContext)servlet.getServletContext(); >> HttpSession session> =(HttpSession)messageContext.getProperty(> HTTPConstants.MC_HTTP_SERVLETREQUEST);>> I am getting java.lang.ClassCastException on casting to HttpSession. I am > doing the right thing>> Thanks>> Shantanu Chawla>>> --> Graduate Student> Department of Computer Science,> San Diego State University --Javier Gonzalez Nicolini-- Graduate Student Department of Computer Science,San Diego State University
Re: How to get hold of current servlet context and session in axis 1.2
If I see it right, you are missing a step. This instruction: (HttpSession)messageContext.getProperty( HTTPConstants.MC_HTTP_SERVLETREQUEST); will return a HttpServletRequest object, not a HttpSessionObject. You need to do: HttpSession session =((HttpServletRequest)messageContext.getProperty( HTTPConstants.MC_HTTP_SERVLETREQUEST)).getSession(); On 8/17/05, shantanu chawla <[EMAIL PROTECTED]> wrote: > my webservice running is axis1.2RC3 needs to access current servlet session > and servletContext. I believe axis is running as a servlet so I can get hold > of the session and servlet context. > > I am using this code: > > > > MessageContext messageContext = > MessageContext.getCurrentContext(); > > HttpServlet servlet = > (HttpServlet)messageContext.getProperty(HTTPConstants.MC_HTTP_SERVLET); > ServletContext servletContext = > (ServletContext)servlet.getServletContext(); > > HttpSession session > =(HttpSession)messageContext.getProperty( > HTTPConstants.MC_HTTP_SERVLETREQUEST); > > I am getting java.lang.ClassCastException on casting to HttpSession. I am > doing the right thing > > Thanks > > Shantanu Chawla > > > -- > Graduate Student > Department of Computer Science, > San Diego State University -- Javier Gonzalez Nicolini
How to get hold of current servlet context and session in axis 1.2
my webservice running is axis1.2RC3 needs to access current servlet session and servletContext. I believe axis is running as a servlet so I can get hold of the session and servlet context. I am using this code: MessageContext messageContext = MessageContext.getCurrentContext(); HttpServlet servlet = (HttpServlet)messageContext.getProperty(HTTPConstants.MC_HTTP_SERVLET); ServletContext servletContext = (ServletContext)servlet.getServletContext(); HttpSession session =(HttpSession)messageContext.getProperty( HTTPConstants.MC_HTTP_SERVLETREQUEST); I am getting java.lang.ClassCastException on casting to HttpSession. I am doing the right thing Thanks Shantanu Chawla -- Graduate Student Department of Computer Science,San Diego State University