Tomcat, pathinfo, and servlets

So today I learned that you can't just access PATH_INFO (pathinfo) information from a servlet when you're using Tomcat (at least not Tomcat 3.2.4 running under Apache). I can access the PATH_INFO information okay under Tomcat running standalone on my PC, but for some reason the same config did not work properly using Tomcat under Apache. (I'll investigate this more in the future.)

Specifically, for me to be able to access PATH_INFO (PathInfo) information in a servlet, I had to add this servlet mapping information to my web.xml file:

    <servlet-mapping>
        <servlet-name>
            Content
        </servlet-name>
        <url-pattern>
            /Content/*
        </url-pattern>
    </servlet-mapping>

The /Content/* is the key. When I just had /Content as the url-pattern like I normally would, I kept getting a 404 error any time I pre-pended anything to the end of my servlet call (for instance, when I tried to hit a URL like http://mondo.devdaily.com/Content/1/1/). But once I changed the servlet mapping as shown above, it started working like a champ.

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.