I have a fully-functional web application hosted in a server. It works perfectly using localhost but when I start Tomcat 7.0.59 on the server and try to reach the application from my local machine, it loads the html and css, and then breaks when trying to hit the first Controller Servlet:
function loadRows(fullAccess)
{
var review_ID = location.search.split('review=')[1];
$.ajax({
url : "LoginController",
type : "post",
data : {
"reviewID" : review_ID
},
...
So I am pretty sure that it is not reading web.xml correctly, which is where my Servlets/Servlet-Mappings 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 adding
<welcome-file-list>
<welcome-file>foo.jsp</welcome-file>
</welcome-file-list>
To see whether the app would break when trying to find foo.jsp and not finding it (the actual file is called index.jsp), but index.jsp is still being rendered so web.xml is clearly not being loaded. Any ideas why? Thanks!
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 configuring Tomcat for the first time, this is where you can define servlet mappings for central components such as JSP. Within Tomcat, this file functions in the same way as described in the Servlet specification. The only divergence in Tomcat's handling of this file is that a user has the option of utilizing TOMCAT-HOME/conf/web.xml to define default values for all contexts. If this method is utilized, Tomcat will use TOMCAT-HOME/conf/web.xml as a base configuration, which can be overwritten by application-specific WEB-INF/web.xml files.
source: https://www.mulesoft.com/tcat/tomcat-configuration
I tink in your case Tomcat does not overwrite the WEB-INF/web.xml and is looking in conf folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With