I have a problem and can’t find information.
I run my web-app from jsp-page which find on folder in “web”. And try to go to servlet
Smth like this
<form action="MyServlet" method="post">
<input type="submit" name="command" />
</form>
In web.xml next
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>mypackage.MyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/MyServlet</url-pattern>
</servlet-mapping>
I thought that this should work but when I run my app I see next url for button

But my goal is get url localhost:8080/TomcatApp/MyServlet
I try to do it using GlassFish and Apache Tomcat 7. I don’t know. Can you help me?
The form’s action is relative to the current page’s path. So if your JSP is at
/TomcatApp/folder/some-page.jsp, just setting the action toMyServletis the same as/TomcatApp/folder/MyServletbecause it automatically uses the current path as a base. To get just/TomcatApp/MyServlet, you need to set your form’s action to either../MyServletor${request.contextPath}/MyServlet.