0

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.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
Alexander Rühl
  • 6,769
  • 9
  • 53
  • 96

1 Answers1

1

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.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Mmm, maybe you could have asked for clarification instead of saying my question makes no sense. I was only trying to explain, that in a previous project, where we used Seam 2, we had the SeamResourceServlet at hand to manage resource files and now we have a project based on JSF2+CDI, so not everything from Seam 2 is at hand anymore but is still needed, that's why I asked for a replacement for that Servlet in either the standard JSF or an extension. The specific problem are image references in css which go through FacesServlet and won't be found then. – Alexander Rühl Sep 13 '12 at 14:25
  • You should have asked about **the specific problem** instead of asking an overly generic question which doesn't make much sense at its own. I would then have posted an answer like this: http://stackoverflow.com/questions/6925733/changing-the-image-of-a-hcommandbutton-using-css/6926193#6926193 – BalusC Sep 13 '12 at 14:30
  • The problem is, that I got a css from the customer which should be left unchanged. And in that css there are references to images which get an .jsf appended while processed by the FacesServlet and thus are not found anymore. So the question is still the same as asked originally - what can I do to get the same functionality I had with the SeamResourceServlet when not using Seam 2 anymore by having made the switch to CDI/JSF2? – Alexander Rühl Sep 13 '12 at 14:41
  • Then just use `` instead of ``. The container's default servlet will serve it up. – BalusC Sep 13 '12 at 14:45