Why is my Tomcat-deployed web.xml not readable by the host server?

I have a fully functional web application hosted on a server. It works fine using localhost, but when I run Tomcat 7.0.59 on the server and try to get to the application from my local computer, it loads html and css and then breaks when I try to get into the first servlet servlet:

function loadRows(fullAccess) { var review_ID = location.search.split('review=')[1]; $.ajax({ url : "LoginController", type : "post", data : { "reviewID" : review_ID }, ... 

Thus, I am sure that it does not read web.xml correctly, in which my servlets / servlets are defined.

This is my web.xml

 <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <display-name>MVCDemo</display-name> <servlet> <servlet-name>LoginController</servlet-name> <servlet-class>mvcdemo.controllers.LoginController</servlet-class> </servlet> <servlet-mapping> <servlet-name>LoginController</servlet-name> <url-pattern>/LoginController</url-pattern> </servlet-mapping> <servlet> <servlet-name>UpdateController</servlet-name> <servlet-class>mvcdemo.controllers.UpdateController</servlet-class> </servlet> <servlet-mapping> <servlet-name>UpdateController</servlet-name> <url-pattern>/UpdateController</url-pattern> </servlet-mapping> <servlet> <servlet-name>SubmitController</servlet-name> <servlet-class>mvcdemo.controllers.SubmitController</servlet-class> </servlet> <servlet-mapping> <servlet-name>SubmitController</servlet-name> <url-pattern>/SubmitController</url-pattern> </servlet-mapping> </web-app> 

I even tried to add

 <welcome-file-list> <welcome-file>foo.jsp</welcome-file> </welcome-file-list> 

To find out if the application will crash when trying to find foo.jsp and not find it (the actual file is called index.jsp), but index.jsp is still displayed, so web.xml is clearly not loading. Any ideas why? Thanks!

+6
source share
2 answers

web.xml

The web.xml file is derived from the Servlet specification and contains information used to deploy and configure the components of your web applications. When setting up Tomcat for the first time, here you can define servlet mappings for central components such as JSPs. Inside Tomcat, this file works in the same way as described in the Servlet specification. The only discrepancy in Tomcat processing of this file is that the user is able to use TOMCAT-HOME / conf / web.xml to determine the default values ​​for all contexts. If this method is used, Tomcat will use TOMCAT-HOME / conf / web.xml as the base configuration, which can be overwritten by WEB-INF / web.xml files for specific applications.

source: https://www.mulesoft.com/tcat/tomcat-configuration

I enter your case. Tomcat does not overwrite WEB-INF / web.xml and looks for the conf folder.

0
source

Try to import the project and get an eye when copying all the files to a new project.

Basically you need to rewrite the deployment descriptor web.xml.

0
source

Source: https://habr.com/ru/post/983918/


All Articles