sitemesh and UTF-8 encoding - encoding

I have an spring-mvc application that is using sitemesh. The problem that I have is that my pages need to be UTF-8 but sitemesh supports ISO-8859-1 charset. Is it possible to configure Sitemesh to work with UTF-8 pages?
I am using a simple example where I am trying to show the page correclty but instead I am getting invalid characters like %¬ etc
The files I am using are:
sitemesh.xml
<sitemesh>
<property name="decorators-file" value="/WEB-INF/decorators.xml" />
<excludes file="${decorators-file}" />
<page-parsers>
<parser content-type="text/html"
class="com.opensymphony.module.sitemesh.parser.HTMLPageParser" />
<parser content-type="text/html;charset=ISO-8859-1"
class="com.opensymphony.module.sitemesh.parser.HTMLPageParser" />
</page-parsers>
<decorator-mappers>
<mapper class="com.opensymphony.module.sitemesh.mapper.ConfigDecoratorMapper">
<param name="config" value="${decorators-file}" />
</mapper>
</decorator-mappers>
</sitemesh>
web.xml
...
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
...
decorators.xml
<decorators defaultdir="/decorators">
<decorator name="main" page="main.jsp">
<pattern>/*</pattern>
</decorator>
</decorators>
main.jsp
<%# taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %>
<html>
<body>
some stuff here
...
<div class="main"><decorator:body /></div>
</body>
</html>
My sample page:
<html>
...
<body>
mùpeeàçè
</body>
</html>
Anyone have any idea?
Thanks

you can try that in web.xml (forceEncoding important, it works for me)
<filter>
<filter-name>SetCharacterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>SetCharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

Have you tried adding a CharacterEncodingFilter to your web.xml? See: http://ibnaziz.wordpress.com/2008/06/10/spring-utf-8-conversion-using-characterencodingfilter/

The reply is kinda late but I hope someone else might benefit from what I wasted hours on. Spring's filter didn't work for me either. I wrote my own and set servletResponse's contentType manually. I have no problems right now.
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
throws ServletException, IOException {
resp.setContentType("text/html; charset=UTF-8");
chain.doFilter(req, resp);
}
<filter>
<filter-name>EncodingFilter</filter-name>
<filter-class>com.muratdozen.mvc.filters.EncodingFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>EncodingFilter</filter-name>
<url-pattern>/ui/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>EncodingFilter</filter-name>
<url-pattern>/WEB-INF/views/*</url-pattern>
<dispatcher>ERROR</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>

Related

Log4j2 in a webapp: MongoCleaner thread creates memory leaks

I'm using log4j 2 with a MongoDBAppender in a webapp (servlet spec 2.5).
Here the web.xml:
<listener>
<listener-class>org.apache.logging.log4j.web.Log4jServletContextListener</listener-class>
</listener>
<filter>
<filter-name>log4jServletFilter</filter-name>
<filter-class>org.apache.logging.log4j.web.Log4jServletFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>log4jServletFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
<dispatcher>ASYNC</dispatcher><!-- Servlet 3.0 w/ disabled auto-initialization
only; not supported in 2.5 -->
</filter-mapping>
Here the log4j2 configuration:
<Configuration status="warn">
<Properties>
<Property name="MongoDbServer">$${jndi:MongoDB.serverAddress.1.host}:$${jndi:MongoDB.serverAddress.1.port}</Property>
<Property name="MongoDbPassword">$${jndi:MongoDB.password}</Property>
</Properties>
<Appenders>
<NoSql name="databaseAppender">
<MongoDb databaseName="LOGS" collectionName="test"
server="${MongoDbServer}" username="LOGS" password="${MongoDbPassword}" />
</NoSql>
<Async name="Async">
<AppenderRef ref="databaseAppender" />
</Async>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Async" />
</Root>
</Loggers>
</Configuration>
When i undeply the webapp, this error log appears:
SEVERE: A web application appears to have started a thread named [MongoCleaner665622824] but has failed to stop it. This is very likely to create a memory leak.
Any suggestion?
Thanks.
You may have found a bug. Can you raise this in the log4j2 Jira issue tracker?
Make sure to close all instances of com.mongodb.MongoClient. e.g:
MongoClient mongoClient= new MongoClient();
// Do something
mongoClient.close();

How to config spring security

I'm trying learning how to protect my web Application using Spring security I have some problems,
this is my web.xml
<welcome-file-list>
<welcome-file>loginPage.html</welcome-file>
<welcome-file>loginPage.htm</welcome-file>
<welcome-file>loginPage.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<!-- Spring context files to be loaded -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/dispatcher-servlet.xml,
/WEB-INF/spring-security.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- filter declaration for Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
and this my spring-security.xml
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<http auto-config="true">
<intercept-url pattern="/*" access="ROLE_USER" />
<form-login login-processing-url="/login" login-page="/loginPage"
username-parameter="username" password-parameter="password"
default-target-url="/secured/mypage" authentication-failure-url="/loginPage?auth=fail" />
<logout logout-url="/logout" logout-success-url="/logoutPage" />
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="srccodes" password="password" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>
and finally my servlet-dispatcher.xml
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/" />
<property name="suffix" value=".jsp" />
</bean>
My application run normally and I have my login page, when I type the right login et password I have error 404 not found!! with url
localhost:8084/LoginFormExampleSpring/secured/mypage
this is my form
<form action="${pageContext.request.contextPath}/login" method="post">
<table>
<tr>
<td>Username:</td>
<td><input type='text' name='username' /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='password'></td>
</tr>
<tr>
<td colspan='2'><input name="submit" type="submit" value="Submit"></td>
</tr>
</table>
</form>
anyone can help me please?
It sounds like you need to add a mapping for /secured/mypage To do so:
Create a file at /WEB-INF/pages/secured/mypage.jsp
Add a mvc:view-controller to dispatcher-servlet.xml
For example:
dispatcher-servlet.xml
<mvc:view-controller path="/secured/mypage"/>

Reading XML in powershell : (407) Proxy Authentication Required error?

I'm trying to read an XML file from my local machine. However, the following code:
$datasourceXmlFilePath=$configuration.config.mondrian.DataSources.filePath
$webXmlFilePath=$configuration.config.mondrian.web.'web-app'.filePath
if(!(Test-Path($datasourceXmlFilePath)))
{
Write-Host "Datasource.xml not found. Exiting the script" -ForegroundColor red
exit
}
if(!(Test-Path($webXmlFilePath)))
{
Write-Host "Web.xml not found. Exiting the script" -ForegroundColor red
exit
}
[xml]$datasourceXml=Get-Content $datasourceXmlFilePath
Write-Host "XML created"
[xml]$webl= Get-content $webXmlFilePath
Write-Host "XML Created"
Keeps giving me the following error:
XML created
Cannot convert value "System.Object[]" to type "System.Xml.XmlDocument". Error: "The remote server returned an error: (407) Pr
oxy Authentication Required."
At line:20 char:11
+ [xml]$webl <<<< = Get-content $webXmlFilePath
+ CategoryInfo : MetadataError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : RuntimeException
Both the XML's are well formed, and I'm stumped as to why one file is successfully read and why the other is not. I tried changing the location of the second xml file, but still got the same result.
I'm using WindowsPowershell_ise v1.0,running on a windows 7 machine.
The xml file for which the problem is occuring is:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Mondrian</display-name>
<description/>
<!-- optional? now in JPivot by default -->
<context-param>
<param-name>contextFactory</param-name>
<param-value>com.tonbeller.wcf.controller.RequestContextFactoryImpl</param-value>
</context-param>
<context-param>
<param-name>connectString</param-name>
<!--<param-value>Provider=Mondrian;Jdbc=jdbc:mysql://localhost:3306/foodmart?user=root&password=;Catalog=/WEB-INF/queries/FoodMart.xml;JdbcDrivers=com.mysql.jdbc.Driver</param-value>-->
<param-value>Provider=Mondrian;Jdbc='jdbc:sqlserver://172.25.37.213;user=QwikSilver_user;password=Newuser123;databaseName=FoodMart;';Catalog=/WEB-INF/queries/FoodMart.xml;JdbcDrivers=com.microsoft.sqlserver.jdbc.SQLServerDriver</param-value>
</context-param>
<!-- optional
<context-param>
<param-name>chartServlet</param-name>
<param-value>/path/to/chartServlet</param-value>
</context-param>
-->
<filter>
<filter-name>JPivotController</filter-name>
<filter-class>com.tonbeller.wcf.controller.RequestFilter</filter-class>
<init-param>
<param-name>errorJSP</param-name>
<param-value>/error.jsp</param-value>
<description>URI of error page</description>
</init-param>
<init-param>
<param-name>busyJSP</param-name>
<param-value>/busy.jsp</param-value>
<description>This page is displayed if a the user clicks
on a query before the previous query has finished</description>
</init-param>
<!--
<init-param>
<param-name>forceExtension</param-name>
<param-value>.faces</param-value>
<description>replace .jsp with .faces</description>
</init-param>
-->
</filter>
<filter-mapping>
<filter-name>JPivotController</filter-name>
<url-pattern>/testpage.jsp</url-pattern>
</filter-mapping>
<listener>
<listener-class>mondrian.web.taglib.Listener</listener-class>
</listener>
<!-- resources initializer -->
<listener>
<listener-class>com.tonbeller.tbutils.res.ResourcesFactoryContextListener</listener-class>
</listener>
<servlet>
<servlet-name>MDXQueryServlet</servlet-name>
<servlet-class>mondrian.web.servlet.MdxQueryServlet</servlet-class>
<init-param>
<param-name>connectString</param-name>
<!--<param-value>Provider=Mondrian;Jdbc=jdbc:mysql://localhost:3306/foodmart?user=root&password=;Catalog=/WEB-INF/queries/FoodMart.xml;JdbcDrivers=com.mysql.jdbc.Driver</param-value>-->
<param-value>Provider=Mondrian;Jdbc='jdbc:sqlserver://172.25.37.213;user=QwikSilver_user;password=Newuser123;databaseName=FoodMart;';Catalog=/WEB-INF/queries/FoodMart.xml;JdbcDrivers=com.microsoft.sqlserver.jdbc.SQLServerDriver</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>MondrianXmlaServlet</servlet-name>
<servlet-class>mondrian.xmla.impl.DynamicDatasourceXmlaServlet</servlet-class>
<!--<servlet-class>mondrian.xmla.impl.DefaultXmlaServlet</servlet-class>-->
<init-param>
<param-name>DataSourcesConfig</param-name>
<param-value>file:D:\setups\apache-tomcat-6.0.24\webapps\mondrian\WEB-INF\datasources.xml</param-value>
</init-param>
<!--
This is an example of how to add a callback to the XML/A servlet.
It must implement mondrian.xmla.XmlaRequestCallback.
<init-param>
<param-name>Callbacks</param-name>
<param-value>com.example.MyCallbackClass;com.example.SomeOtherCallback</param-value>
</init-param>
-->
</servlet>
<!-- jfreechart provided servlet -->
<servlet>
<servlet-name>DisplayChart</servlet-name>
<servlet-class>org.jfree.chart.servlet.DisplayChart</servlet-class>
</servlet>
<!-- jfreechart provided servlet -->
<servlet>
<servlet-name>GetChart</servlet-name>
<display-name>GetChart</display-name>
<description>Default configuration created for servlet.</description>
<servlet-class>com.tonbeller.jpivot.chart.GetChart</servlet-class>
</servlet>
<servlet>
<servlet-name>Print</servlet-name>
<display-name>Print</display-name>
<description>Default configuration created for servlet.</description>
<servlet-class>com.tonbeller.jpivot.print.PrintServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DisplayChart</servlet-name>
<url-pattern>/DisplayChart</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Print</servlet-name>
<url-pattern>/Print</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>GetChart</servlet-name>
<url-pattern>/GetChart</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>MDXQueryServlet</servlet-name>
<url-pattern>/mdxquery</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>MondrianXmlaServlet</servlet-name>
<url-pattern>/xmla</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<taglib>
<taglib-uri>http://www.tonbeller.com/wcf</taglib-uri>
<taglib-location>/WEB-INF/wcf/wcf-tags.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://www.tonbeller.com/jpivot</taglib-uri>
<taglib-location>/WEB-INF/jpivot/jpivot-tags.tld</taglib-location>
</taglib>
</web-app>
Any help would be appreciated.
I had a similar problem loading an XML. I didn't require proxy access but had trouble with circumventing it, initially I tried this:
set-itemproperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name ProxyEnable -value 0
It worked as a user but not as administrator.
So I tried this:
[System.Net.WebRequest]::DefaultWebProxy = $null

primeFaces : fileUpload to byte[]

I am trying to get the uploaded image of <p:fileUpload> as byte[] and persist it in DB by JPA. But I'm facing a problem and I'm not even sure if I'm coding it the right way.
This is the entity:
#Entity
class Object {
#Lob
#Column(name = "image")
private byte[] image;
//...
}
Managed bean:
#ManagedBean
class MyBean {
private Object ob = new Object();
#EJB
private ObjectFacadeLocal of;
public void handleFileUpload(FileUploadEvent event) {
byte[] content = event.getFile().getContents();
ob.setImage(content);
}
public String submit() {
//...
of.create(ob);
return "anotherpage"
}
The ObjectFacade persists Object in database.
This is the JSF page called form.xhtml:
<h:form id = "upi" enctype = "multipart/form-data">
<p:fileUpload fileUploadListener="#{MyBean.handleFileUpload}"
allowTypes="*.jpg;*.png;*.gif;" description="Images"/>
<h:commandButton value = "Submit" action = "#{MyBean.create()}">
</h:commandButton>
</h:form>
First of all, I'm getting a warning in form.xhtml that it cannot find the handleFileUpload method, but I can still run it. When I press the submit button, then nothing happens, the page just refreshes. If I remove the enctype attribute then the object gets persisted, but not with the image.
Any ideas?
Update:
This is my web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee /web-app_3_0.xsd">
<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>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/blog.xhtml</welcome-file>
</welcome-file-list>
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
</web-app>
You forgot to read the PrimeFaces User Guide. Here's an extract of <p:fileUpload> chapter:
Getting started with FileUpload
First thing to do is to configure the fileupload filter which parses the multipart request. FileUpload filter should map to Faces Servlet.
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
Without that filter, no one action method inside a <h:form enctype="multipart/form-data"> can be invoked nor will the submitted data be properly parsed.
As to the warning that the method cannot be found, this is related to the IDE which you're using which is pretending to be smarter than it is. Disable EL validation in that IDE to avoid those confusing warnings and look if you can't upgrade the IDE.

javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20

I have created simple Java Dynamic Web project in Eclipse. I host my project on Glassfish 2.1.1. When I try open p1.jsf page in browser I got following error:
javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20.
I have no idea how to correct this error...
Here is may p1.jsf definition:
<%# page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%# taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%# taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<f:view>
<h:outputLabel value="outputLabel"></h:outputLabel>
</f:view>
</body>
</html>
My 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" id="WebApp_ID" version="2.5">
<display-name>web4</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>FacesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
</web-app>
My faces-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
version="1.2">
</faces-config>
Error details from Glassfish log:
PWC1406: Servlet.service() for servlet FacesServlet threw exception javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20
org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:860)
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:723)
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:558)
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:490)
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:382)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:468)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:873)
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:723)
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:558)
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:490)
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:382)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:468)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:873)
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:723)
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:558)
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:490)
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:382)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:468)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427)
org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:873)
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:723)
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:558)
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:490)
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:382)
com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:468)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
FacesServlet should be mapped on an url-pattern of *.jsf (or anything else other than *.jsp).
No javax.faces.DEFAULT_SUFFIX is needed in web.xml if you already use JSP. The JSP page itself must actually be named pagename.jsp (and thus not pagename.jsf, this is the root cause of the recursive forward calls).
Open the page in the webbrowser using the *.jsf suffix: http://example.com/context/pagename.jsf (and thus not by pagename.jsp, else you would get RuntimeException: FacesContext not found).
This means that recursive internal forwards occur. A few things to observe:
make sure you are accessing the page via the right suffix. i.e. http://localhost:8080/app/p1.jsp, and not p1.page - you have mapped the jsf suffix to be .jsp
check your navigation rules in your faces-config.xml
make sure you have the following context-param defined:
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.jsp</param-value>
</context-param>
To summarize - the javax.faces.DEFAULT_SUFFIX determines the file extension under which the page are sought, and the <url-pattern> of the faces-servlet determines the way the jsf pages are accessed by clients (browsers)