I have worked JSF application under Tomcat. In the same project I configured, also using, PHP as described in Caucho Resin site (Link)
But when I try to include separated PHP working script into JSG page, page is fails.
I have test.php
with:
<?php
print "hello world";
?>
in web.xml
I have added:
<servlet>
<servlet-name>Quercus Servlet</servlet-name>
<servlet-class>com.caucho.quercus.servlet.QuercusServlet</servlet-class>
<init-param>
<param-name>license-directory</param-name>
<param-value>WEB-INF/licenses</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Quercus Servlet</servlet-name>
<url-pattern>*.php</url-pattern>
</servlet-mapping>
Also added resin.jar
into web-inf/lib
when I call test.php
directly it is working, but when I try to include like this:
<ui:include src="test.php"/>
or write php code direct in JSF page it fails.
Here is the exception:
javax.faces.view.facelets.FaceletException: Error Parsing /test.php: Error Traced[line: 5] Premature end of file.
at com.sun.faces.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:429)
at com.sun.faces.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:403)
at com.sun.faces.facelets.compiler.Compiler.compile(Compiler.java:124)
at com.sun.faces.facelets.impl.DefaultFaceletFactory.createFacelet(DefaultFaceletFactory.java:319)
at com.sun.faces.facelets.impl.DefaultFaceletFactory.access$100(DefaultFaceletFactory.java:92)
Any body tried this kind of experiment?
When you're calling your PHP page directly, it is being processed by your Quercus Servlet with no problem at all. But when you call your PHP page included inside a non-PHP page, like a JSP (or JSF or XHTML or another file extension), your Quercus Servlet is not processing it thus giving you this errors.
You could do a mix of parsing the page with both Quercus Servlet and/or Faces Servlet (I haven't tested this so I'm not sure if it will work). Another option could be not using the PHP scripts in your JSP/JSF pages directly but using them to process the actions i.e.
<form action="test.php">
.Note that this is not a JSF nor Tomcat nor Resin nor Caucho problem, it is a servlet problem or an ever worse, a design problem. This leads to a question: Why would you want such an odd design in your web application?