When you deploy your application into servlet container, your URLs may be prefixed by the context path identifying your application among other applications in that container (i.e. /ReceiveMessagesServlet
becomes /MyApp/ReceiveMessagesServlet
).
Therefore you should take that possibility into account and modify your URLs accordingly, for example, with JSTL's <c:url>
:
<form action="<c:url = value = '/ReceiveMessagesServlet' />" method="post">
Alternatively, without JSTL:
<form action="${pageContext.request.contextPath}/ReceiveMessagesServlet" method="post">