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:
1 2 3 4 5 6 7 8 | <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.
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步