from the idea, the project works fine, if I upload the project to the root of the tomket also works fine, but if the deployment from the tomkote project manager and launch the application at localhost: 8080 / app , then when going to the second page localhost: 8080 / app / second_page an error occurs .

On the first page there is a form:

<form onsubmit="return checkForm(this)" action="/second_page" method="POST"> <div id="fields_container"> <div> <div class="element">First name:</div> <input id="name" type="text" name="firstName"/> <span id="err_name" class="error"></span> </div> </div> <div> <input type="submit" value="Submit"> </div> </form> 
при нажатии на "submit" приложение перебрасывает не на **localhost:8080/app/second_page** а на **localhost:8080/second_page**

my web.xml

 <servlet> <servlet-name>addServlet</servlet-name> <servlet-class>com.company.MyServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>addServlet</servlet-name> <url-pattern>/second_page</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>/WEB-INF/pages/index.jsp</welcome-file> </welcome-file-list> <error-page> <exception-type>java.lang.Throwable</exception-type> <location>/WEB-INF/pages/error.jsp</location> 

How can I solve this problem. Thank.

  • one
    Please indicate the error in the question - Mikhail Vaysman
  • Maybe you manually copied the jdbc driver to the root tomkata, there it is visible. And from the app is not visible, because web applications are isolated from each other. You must either include the jdbc driver in the application (in WEB-INF/lib ) or place it in the server's shared library folder ( $CATALINA_BASE/lib or $CATALINA_HOME/lib ?). It’s hard to come up with another reason if everything else is right. In general, as stated in the comments above, an error in the studio. - Sergey
  • @MikhailVaysman I changed the question because I realized that the problem was not with JDBC, but that I did not fully understand how Tomcat works. Be kind, look, maybe you can tell me. - Mihail Gogol
  • @Sergey Changed the question, tell me, if possible, the answer. - Mihail Gogol
  • So you have action="/second_page" , which means localhost:8080/second_page . Must be action="${request.contextPath}/second_page" . All absolute links (starting with / ) to the application pages should be of such a kind as to make them independent of the current context root . Another option is to use relative links (should not begin with / ). If the page is in the same directory, then action="second_page" , if in a neighbor, then action="second_folder/second_page" , in parent action="../second_page" - Sergey

0