0

I made a simple web app called "ServletContextExample" in which I access a servlet with a URL in an HTML page. The URL code was -

<a href = "/ServletContext/listenerTest.do">Click me</a>

Obviously, I get the 404 error when I click this link. ServletContext should be changed to ServletContextExample. Despite changing the code, rebuilding project, & republishing, restarting tomcat in Eclipse, I still get the 404 error. However, the Servlet can be "accessed" by entering its url manually. How do I resolve this problem ?

404 error details - 

HTTP Status 404 - /ServletContext/listenerTest.do
The requested resource is not available.
Erran Morad
  • 4,563
  • 10
  • 43
  • 72
  • EDIT - Restarting eclipse solved the problem. But, I'd still like to know why this problem occurred in the first place ? – Erran Morad Apr 30 '14 at 21:25
  • If this was JSP or Facelet instead of HTML, then you can append the [`HttpServletRequest#contextPath`](http://docs.oracle.com/javaee/7/api/javax/servlet/http/HttpServletRequest.html#getContextPath()) to your URL. You can do it easily using expression language: `Click me` – Erran Morad Apr 30 '14 at 21:45
  • What does `ServletContext` correspond to in this url? Why not just `listenerTest.do`? – developerwjk Apr 30 '14 at 23:35
  • @developerwjk - `ServletContext` is the name of my dynamic web project in eclipse. Earlier i was not using it in the url and was getting the 404 error all the time. – Erran Morad Apr 30 '14 at 23:48

0 Answers0