3

I'm trying to serve static content (a HTML form that calls a Jersey REST resource) from the same webapp as the servlet that handles the requests to the resource. As I understand I can filter requests to static content away from the Jersey servlet. My web.xml is as follows, but at the moment I am unable to access the static content nor the resource...both were working separately.

<filter>
    <filter-name>my-filter</filter-name>
    <filter-class>com.sun.jersey.spi.container.servlet.ServletContainer</filter-class>
    <init-param>
        <param-name>com.sun.jersey.config.property.WebPageContentRegex</param-name>
        <param-value>/*.html</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>my-filter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
    <servlet-name>my-service</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.mydomain.ws.myservice</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>my-service</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
pertinky
  • 103
  • 2
  • 10

2 Answers2

3

FWIW your original problem was probably because the param-value for the WebContentRegex was not a regular expression. Ok techincally it was, but it is not matching what you probably want. You should try something like /.*.html instead.

Joe
  • 31
  • 2
0

I setup my services such that the rest service are under their own subpath separate from the static content:

<servlet-mapping>
    <servlet-name>ServletAdaptor</servlet-name>
    <url-pattern>/rest/*</url-pattern>
</servlet-mapping>
jayraynet
  • 896
  • 1
  • 7
  • 24