How to configure jsf with jsp
I want to use jsf tags in jsp. How to do this? I configured the pom file with jsf dependency which is given below
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.0.3</version>
</dependency>
开发者_开发知识库<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.0.3</version>
</dependency>
and added the following in web.xml
<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>*.jsp</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
after deploying the war file I am getting the java.lang.NullPointerException
Your FacesServlet
URL pattern is wrong. It should not override the one of the JspServlet
. This way JSPs can never run (and thus JSF can never use them).
The FacesServlet
URL pattern should be different and unique. Use for example *.jsf
.
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
Said that, with preferring the legacy JSP over its successor Facelets, you'll miss a lot of awesome templating and compositing features offered by Facelets. I strongly recommend to reconsider your odd choice for the JSF 2.0 view technology.
I think you want to do the wrong thing. JSF is a framework that has a different philosophy than JSP.
You can have JSF and JSP working together, but it is the other way around - you configure JSF to use JSP as its view technology. But you should not do that unless you are very well aware of why you need it. The default view technology is Facelets and it is much better suited for JSF.
JSF is a framework and jsp is just a file. Yes, you can use jsp files in JSF framework as well without using greatest tool Facelets. Using Facelets in JSF you can only use xhtml files.
If you still want to use jsp files then either you have to use core servlets or use JSF without facelets.
精彩评论