Thanks Marc, Using the full path to the context doesn't help. Darn. I'll try a more sophisticated IDE and see if it provides any insight, but I am not convinced that I need that at this point. As far as I can tell, this should be working...
-corey -----Original Message----- From: Marc Farrow [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 26, 2006 7:30 PM To: Tomcat Users List Subject: Re: JSPs, contexts, Tomcat 5.5.16+ and NPEs I don't have much to add, but I will try to give a suggestion or pointers for you to research. I just wanted to start off by saying (in my opinion) this was an excellent post and it described the problem and situation very clearly. Have you tried getServletContext().getContext("/web/mysite")? Also, since you are making this call in a JSP page, the current context is the JSP servlet provided by Tomcat. You are correct in trying to get a foreign context. I am not sure what IDE you use, but in NetBeans and also in Eclipse in the past I was able to debug my Servlet/JSP and use watches, etc to play with the code to get my RequestDispatcher to work properly. HTH or at least points you in the right direction. Marc On 4/26/06, Corey Kaiser <[EMAIL PROTECTED]> wrote: > > I've finally nailed down what I think my problem with Tomcat 5.5.16 and > greater is, and condensed it into this easy-to-use, FunSize-ed post. > > I have a webapp that is at the root of my appBase, defined in a Context > element in my server.xml, like so: > > <Host name="www.mysite.com" appBase="/web/mysite" unpackWARs="true" > autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> > > <Context path="" docBase="" reloadable="true" crossContext="true"> > <Parameter name="propfile" value="myProps.properties"/> > </Context> > > </Host> > > I have a servlet, myServlet, defined in my webapp's web.xml (which is > located on the filesystem at /web/mysite/WEB-INF/web.xml) and mapped to > /servlets/myServlet (accessible and working at > www.mysite.com/servlets/myServlet) > > I have a JSP that lives on the filesystem at /web/mysite/myDir/myPage.jsp, > to be accessed at www.mysite.com/myDir/myPage.jsp and contains code > similar > to this: > > <% ServletContext ctx = pageContext.getServletContext().getContext("/"); > > String myUrl = "/servlets/myServlet"; > > RequestDispatcher dispatcher = ctx.getRequestDispatcher(myUrl); > > dispatcher.include(request, response); > > out.clear(); > > out = pageContext.pushBody(); %> > > > > The global web.xml is untouched, and there's really only my servlet > mappings > in the webapps web.xml. > > With this config, the www.mysite.com/myDir/myPage.jsp works great on > 5.5.15 > and below. > > On 5.5.16+ I get a NullPointerException, that alludes to the > RequestDispatcher line. I'm guessing that is because getServletContext() > is > returning null rather than a root context, or something... > > If I copy the myPage.jsp to the root (/web/mysite/myPage.jsp) on 5.5.16+, > it > works fine. > > I have tried replacing the path="" with path="/" from the Context > definition and it's exactly the same. Same goes for removing the > docBase="". > Changing the getContext("/") in the jsp to getContext("") produces the > same > result, as does removing it and just using getServletContext(). > The servlet doesn't appear to be the problem, as I can replace it with the > simplest of servlets and get the same problem. > > I'm running Apache 1.3.34 with mod_jk 1.2.15, and the appropriate > JkMounts, > workers, etc., oh and yes, I'm blocking access to WEB-INF and META-INF in > my > Apache config. I know it's a bit wonky, but I'm trying to shoehorn an old, > large collection of servlets that run great on Apache + JServ into a > Tomcat > configuration. This is the last little nagging problem. > > Many thanks in advance for any help. > -corey > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Marc Farrow --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]