I want to put my JSF 2.0 xhtml files under WEB-INF\jsf. How do I access them then? I know that anything inside WEB-INF isn’t exposed to the outside, so I need a controller to redirect me to the corresponding JSP, right? (This is also the model 2 pattern iirc).
Can I achieve this with a parameter inside web.xml/faces-config.xml? I think the FacesServlet is the controller of my webapp so it should serve this purpose?
And another question for understanding the Model 2 Pattern. Does every action have to go first to a servlet which then handles the next possible step? So a simple <a href="anotherPage.html" /> is forbidden in this pattern since it doesn’t go to the controlling servlet?
You cannot. Files in
/WEB-INFfolder are not directly accessible.There are two options to workaround the problem of JSF source files being public accessible.
Map the
FacesServleton*.xhtmlinstead of*.jsf.Or, restrict direct access on
*.xhtmlby a<security-constraint>inweb.xml.See also:
The
FacesServletalready does that. It’s the controller. With JSF you already end up with a simple javabean as model and JSP/Facelets file as view. TheFacesServletas being the controller has already taken all the nasty work of request parameter gathering, validation, conversion, model updating and navigation from your hands.See also:
No, it’s perfectly fine. The controller will kick in whenever needed. If the resource doesn’t need a controller (i.e. static resource), then you also don’t need to let it pass through some controller.
In the future, please ask multiple questions in separate Stack Overflow questions.