I have tomcat 5.0
the context of my web application is : /toddstore
consider the following url :
login.html contains a form to perform a log in operation.
invoking login.html by the browser, I got that the resource is not found.
changing the action to : action="/toddstore/loginservlet">
it works !
AFAIK, the first approach should work, coz the url is relative to the context path.
any ideas ??
coz the url is relative to the context path.
Incorrect. URLs referenced from the HTML pages such as form actions, images, style sheets, script files and so on are server relative. Otherwise, how would the container know which web application to route the request to? The context path must be used in such situations.
Otherwise, how would the container know which web application to route the request to? The context path must be used in such situations.
If you use this sample code:
<form name="testForm" action="TestServlet">
The TestServlet is looking from context root on. I don't have to include the context path in my action. If I put a "/" in front of TestServlet then it will look from the server port number, such as localhost:8080/TestServlet, but if I leave off "/", it will look at localhost:8080/context_root/TestServlet. The server handles it.
Actually, no it will not. It doesn't work (because the leading slash makes the URL server-relative), but it has nothing to do with the port number.
Your right, i meant what you said but I didn't know the correct wording. Up in the URL it is placed right after the port number, but nothing to do with the port number. Sorry for the confusion.