Beginner question about JSF, JSP and Apache

Hi there,

I'm having a example page to test some stuff of JSF, like:

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<f:view>

<h:outputText value="#{helloWorld.outputText}"/>

</f:view>

using a managed bean... (in the faces-config.xml file I've defined the managed bean)

Ok.. at this point all is right!

My question is about the web.xml file!

In this file I had this code:

<servlet>

<servlet-name>Faces Servlet</servlet-name>

<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>

<load-on-startup>1</load-on-startup>

</servlet>

<!-- Faces Servlet Mapping -->

<servlet-mapping>

<servlet-name>Faces Servlet</servlet-name>

<url-pattern>*.faces</url-pattern>

</servlet-mapping>

<servlet-mapping>

<servlet-name>Faces Servlet</servlet-name>

<url-pattern>*.jsf</url-pattern>

</servlet-mapping>

My doubt is: Why can't I do a mapping to a .jsp file? Why it gives me an error?

Ok so we map the .jsp files to .jsf (or .faces) ended url's... but if we try to get the page using a .jsp ended url.. it gives an error (org.apache.jasper.JasperException). Why?

How can we hide the user of using a .jsp ended url... something like giving a "resource not avaiable error"?

Thanks in advance.

Tiago.

[1726 byte] By [tcavaleiroa] at [2007-11-27 2:49:40]
# 1

Hello,

You have to pass through the JSF sevlet to access a JSP pages with JSF component.

You can create a restriction like this :

<security-constraint>

<display-name>Restrict JSP pages</display-name>

<web-resource-collection>

<web-resource-name>JSP</web-resource-name>

<url-pattern>*.jsp</url-pattern>

</web-resource-collection>

<auth-constraint>

<description>Only developer can access JSP</description>

<role-name>developer</role-name>

</auth-constraint>

</security-constraint>

This should display an access error page when you try to access a JSP file directly

Regards,

Sebastien Degardin

sdegardina at 2007-7-12 3:21:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Ok, thanks for the help!Tiago.
tcavaleiroa at 2007-7-12 3:21:12 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...