4

I am testing the application "jsf-blank" from coreservlets site in order to understand how jsf works but my browser doesn't show the content of the xhtml page.

I use Tomcat 6 and Eclipse Indigo.

Have you any idea why the page is blank in my browser ?

Thank you for your help.

Thank you but it doesn't work with jsp directive and this is the content of my web.xml :

<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>
<context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
</context-param>
<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>

Last update :

I tried your solutions but I have the same problem, jsf tags aren't rendered by browser (I am a newbie in JSF).

My test is very simple :

web.xml :

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"                             xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>index.xhtml</welcome-file>
</welcome-file-list>

index.xhtml :

  <!DOCTYPE html>
  <html lang="en"
     xmlns="http://www.w3.org/1999/xhtml"
     xmlns:f="http://java.sun.com/jsf/core"
     xmlns:h="http://java.sun.com/jsf/html"
     xmlns:ui="http://java.sun.com/jsf/facelets">
     <h:head>
       <title><h:outputText value="First JSF Application" /></title>
     </h:head>
     <h:body>
        <h:outputText value="Test" /> 
     </h:body>
   </html>

Context name : jsf-blank

I test with url : http://localhost:8080/jsf-blank/index.xhtml

Result : blank page

Last update :

Thank you, my problem is solved, I think the origin of problem was rich-faces 3.3 jars in my tomcat's folder shared/lib.

I removed these jars and now it's working, do you know why it's a problem ?

user1008704
  • 43
  • 1
  • 1
  • 4

3 Answers3

5

That can happen when you have sent a request whose URL does not match the URL pattern of the FacesServlet which in turn causes that the JSF works won't run at all. According to the URL pattern of your servlet mapping, you have to request your XHTML page with .jsf extension. Imagine that you've an index.xhtml, then you'd need to invoke it by http://localhost:8080/contextname/index.jsf.

I however recommend to just replace the *.jsf URL pattern by *.xhtml so that you never need to worry about and fiddle with suffixes. Change your web.xml as follows:

<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>

<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

<welcome-file-list>
    <welcome-file>index.xhtml</welcome-file>
</welcome-file-list>

And open the page by http://localhost:8080/contextname/index.xhtml.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
1

Basically, MyFaces' JSF 2 implementation is returning blank pages whenever there's any error on either a configuration file or whatever. Worse yet, the errors aren't being sent to the log, either. Use Mojarra (Oracle's JSF 2 implementation) instead, and you'll start getting clear error messages.

Haroldo_OK
  • 6,612
  • 3
  • 43
  • 80
0

RichFaces has it's own configs in web.xml (RichFaces Filter etc.), so if you don't want to use it, you should remove the library because you're not applying any suitable configuration for it, in order to trigger it properly.

MShNajar
  • 56
  • 7