I keep getting error 404 when trying to access an HTML file in my Dynamic Web Project.
Here 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" id="WebApp_ID" version="3.0">
<display-name>NMWebServices</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>NMServlet</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.nilaymodi.services</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>NMServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
my html file:
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Inspiration Generator</title>
</head>
<body>
<p>testing</p>
</body>
</html>
my java rest service class
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@Path("/inspiration")
public class Endpoints {
@GET
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public Response getInspiration() {
Inspiration inspiration = InspirationFactory.generate();
Gson gson = new Gson();
String result = gson.toJson(inspiration, Inspiration.class);
return Response.ok(result, MediaType.APPLICATION_JSON).build();
}
@GET
@Path("/test")
@Produces(MediaType.TEXT_PLAIN)
public Response testConnection() {
return Response.ok("Sucess! Service is running.", MediaType.TEXT_PLAIN).build();
}
}
which works completely fine at the url "localhost:8080/apps/inspiration/"
my context root is "apps" and I am trying to hit the HTML file with the url "localhost:8080/apps/inspiration.html" which is the url eclipse gives when I right click on the HTML file and go to run on server. I'm using Tomcat v7.0.70
any assistance would be greatly appreciated!
You don't seem to have anything written to serve static content. You'll need to do something like this.