I can access the servlet through <jsp:include> tag. However, when I create a link to the same servlet using <a> tag or <form action="">, it returns 404 error.
The both ways work perfectly fine on my development computer and its Tomcat, but ocne it's deployed to a web server, it starts happening.
I have done following things:
1. Since the Tomcat version is 5.5 in the deployment server and the Tomcat version is 7.0 in my development server, I tried to lower my servlet API version to 2.4. It didn't fix the problem.
2. Even though my servlet only calls the methods on my model class and does not generate any output, I tried to set content type to html/text. It didn't fix the problem.
What could be the reason?
Thanks in advance.
Obessed with computers, mobile devices, linux, coding, scuba diving, boxing and coffee...
Make sure that the URL that you are using starts with the context path of the web application, which should be followed by the servlet mapping. For example: "/context-path/servlet-path". Using page-relative addressing in an anchor tag, or as a form action, is almost guaranteed to cause issues. Even if you can get it to work, it is fragile and can break with the least little of changes.
Does this mean I cannot deploy the application on the root of my website?