Why are you trying to access
/Example1/WebContent/MyServlet
?
Everything in the WebContent
directory in your project will end up being at the root of the generated war
file. Everything not in WEB-INF
will be accessible, so you can do
/Example1/index.jsp
Otherwise, you have to go through a Servlet
. You don't have a url mapping that matches
/Example1/WebContent/MyServlet
and that therefore gives you a 404.
You do have a url mapping for
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/MyServlet</url-pattern>
</servlet-mapping>
You can access that at
/Example1/MyServlet
Note that submitting this form in a browser
<form action="MyServlet">
<input type="submit" value="Send" />
</form>
depends on your current URL. If you had made your previous request to
/Example1/index.jsp
then submitting the form will send the request to
/Example1/MyServlet
If you were on
/Example1/some/random/path
then submitting will send the request to
/Example1/some/random/MyServlet
If you want to make your request always go to the same URL, you should make your path absolute
<form action="${pageContext.request.contextPath}/MyServlet">
<input type="submit" value="Send" />
</form>