Search code examples
jsf-2java-ee-6tomcat7cdi

What is the replacement for Seam Resource Servlet in Java EE 6?


In our previous Seam 2 projects we had the following part in web.xml to care for loading static resources such as css or img:

  <servlet>
    <servlet-name>Seam Resource Servlet</servlet-name>
    <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>Seam Resource Servlet</servlet-name>
    <url-pattern>/seam/resource/*</url-pattern>
  </servlet-mapping>

What is the replacement for that when using CDI + JSF2? Can it be done with standard Java EE 6 mechanism or do we need a CDI extension or any other additional library?

PS: The project is maven based and deployed on a tomcat 7, so if some extensions are needed, I'll be very happy about according dependencies.


Solution

  • Seam 2 was never been part of Java EE 5, so there's no means of a "replacement" in Java EE 6. You probably need to look at Seam 3 or whatever successor Seam 2 has.

    "Static resources" are in a standard servlet container already fully automatically and transparently handled by the container's builtin default servlet. Just drop the files directly in the public webcontent folder (there where you also put your JSP/Facelets files).

    JSF2 has however a new resource handling mechanism which allows automatic resource inclusion using @ResourceDependency and so on in components/renderers, but this is already taken into account by the FacesServlet itself and the new JSF 2.0 <h:head> and <h:body> components. I'm however not sure if that's related to whatever Seam 2 did, I've never really used Seam.

    CDI has very little to do with this all, it's a bean management API, not a static resource management API.