• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ServletContext returns null on Tomcat?

 
Mark Stein
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The basics... Apache 1.3x coupled to Tomcat 4.1 using mod_jk. Apache's httpd.conf is set up to send *.jsp and /servlet/* to tomcat. Tomcat has the context path set to "" (the default) and the doc path set to "public_html (WEB-INF is under public_html). Servlets are mapped "/servlet/servletname" Jsp's work fine, and so do simple servlets (both mapped, and using the invoker statement).

My problem is when I try to use a RequestDispatcher (both ServletContext, and HttpRequest). I've managed to track it down to the fact that Tomcat is returning null when I getServletContext(). It's not the code because it works on Resin.

My guess is it's either a Context path issue in server.xml, and/or a servlet mapping problem. I've tried setting the context path to "/" and that gives me a 500 error on tomcat. I've tried moving the webapp to a different dir and setting a new context path and that gives me a 404 error (using both mapping and invoker).

Anyone have any clues what's up?

Thanks
 
Mark Stein
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After much hair pulling, I managed to solve the problem, but I have no idea why... Maybe someone can explain it to me....

On both Tomcat 4.0 and Resin, getServletContext() gave me a servlet context. On Tomcat 4.1, I had to use getServletConfig().getServletContext().

Anyone ever hear of this before, or have any ideas?

Thx.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic