On Sunday 30 June 2002 7:32 pm, Peter Lin wrote: > --- John Baker <[EMAIL PROTECTED]> wrote: > > Hello. > > > > I'm am trying to write a Valve, very much like > > SingleSignOn but for our > > authetnication system that uses more than just a > > username and password. I > > want my Valve to pass login information from one > > Session to another when a > > user uses different webapps (Contexts). > > > > I am nearly there codewise, but have a small > > problem. I do not seem to be able > > to get the session from the request! I've tried > > calling request.getSession() > > and request.getSession(true) yet both return null. > > It's hardly worth pasting, > > but: > > > > public void invoke(Request request, Response > > response, ValveContext context) > > throws IOException, ServletException > > { > > System.out.println( > > ((HttpRequest)request).getSession(true) ); > > > > Will always print null. > > Shouldn't you be using this instead? > > (HttpServletRequest request, HttpServletResponse > response, ValveContext context)
Err, the inteface Valve clearly defines: public void invoke(Request request, Response response, ValveContext context) throws IOException, ServletException; > Also, why are you casting HttpSession to HttpRequest? I'm not, I'm casting request to HttpRequest so I can call getSession. I did cut some of my code but I do check to make sure request can be casted. See org.apache.catalina.authenticator.AuthenticationBase and the method getSession(HttpRequest request, boolean create); as this gives a clear example of what I'm trying to do. yet it doesnt work for me! John -- John Baker, BSc CS. Java Developer, TEAM Slb. (http://www.teamenergy.com/) The views expressed in this mail are my own. -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>