I've just started writing some java servlets and running them with Tomcat (v7). My understanding of how the directory structure works is that URLs are relative to the name of your application:
- So if my app is MyWebApp then by visiting http://server/MyWebApp I'll see, for example, the "index.jsp" file I created in the root directory of my web app.
- If said index.jsp has a form with POSTs to "submit" then the broswer will send to http://server/MyWebApp/submit
And in my web.xml file I can point a class which extends HttpServlet to handle this POST request. Something like:
<servlet> <servlet-name>MyHandler</servlet-name> <servlet-class>org.me.handler</servlet-class> </servlet> <servlet-mapping> <servlet-name>MyHandler</servlet-name> <url-pattern>/submit</url-pattern> </servlet-mapping>
However, suppose my form POSTs to "/submit". Then the browser sends the request to http://server/submit
- I don't see any way to intercept this from my web app.
One approach is just to deploy my web app as the ROOT. Is there another approach?