Reputation: 4150
I have found a way to protect direct access fofr my .xhtml
Pages by having this security Constraint in my web.xml:
<security-constraint>
<display-name>Restrict raw XHTML Documents</display-name>
<web-resource-collection>
<web-resource-name>XHTML</web-resource-name>
<url-pattern>*.xhtml</url-pattern>
</web-resource-collection>
<auth-constraint />
</security-constraint>
however this seems to restrict My welcome file Listing in the web.xml which I have like this:
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
I also cannot Seem to access My Pages from beans in this method:
public void getBreakEvenProductPage(ComponentSystemEvent event) {
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest origRequest = (HttpServletRequest) context.getExternalContext().getRequest();
String contextPath = origRequest.getContextPath();
try {
FacesContext.getCurrentInstance().getExternalContext()
.redirect(contextPath + "/faces/BreakEvenProfProduct.xhtml");
} catch (IOException e) {
log.debug(Level.FATAL, e);
}
}
xhtml for above method:
<p:menuitem value="Break Even Rate Profit report"
action="#{Navigation.getBreakEvenProductPage(event)}"/>
My problem is that I have come up with another Problem by trying to address a problem. How Can I access these pages with the security constraint in place??
Upvotes: 0
Views: 518
Reputation: 410
You could try to change
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
to
<welcome-file-list>
<welcome-file>faces/index.jsf</welcome-file>
</welcome-file-list>
And make sure you have following lines in your web.xml<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
Upvotes: 1