0

I created a Dynamic Web Project in Java using Eclipse JEE to make a REST web service. I am trying to add a html file simply to add a form that allows me to test my web services in a faster and easier way.

I have read that just placing the html files under the WebContent folder or the WEB-INF folder does the trick. But since I already have a web.xml file it's disrupting the expected behaviour:

This is my web.xml file:

<?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"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
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">
<servlet>
    <servlet-name>REST web service</servlet-name>
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
    <init-param>
        <param-name>jersey.config.server.provider.packages</param-name>
        <param-value>ws,com.fasterxml.jackson.jaxrs.json</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>REST web service</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>

So where should I place my html files and what should I modify in my web.xml file to get it working (if it needs to be modified)?

dabadaba
  • 9,064
  • 21
  • 85
  • 155

1 Answers1

0

In your web.xml you have a mapping for /* which means that the REST web service will receive all the connections, you can either make REST web service return the appropriate resource based on the url or change its mapping (<url-pattern>) to something more specific.

Titus
  • 22,031
  • 1
  • 23
  • 33
  • could you give me an example of how I could set that up? – dabadaba Oct 22 '15 at 12:59
  • That depends on what you're trying to do, the simplest way to resolve this will be to change the mapping in the `web.xml` file to something like this `/api/*` – Titus Oct 22 '15 at 16:30