File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes JSF application on Apacher web server and Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "JSF application on Apacher web server and Tomcat" Watch "JSF application on Apacher web server and Tomcat" New topic
Author

JSF application on Apacher web server and Tomcat

anyz mick
Greenhorn

Joined: Aug 09, 2004
Posts: 15
I have a JSF based web application using facelets (XHTML). It works perfect on Tomcat. For demo purpose i deployed it on hosting server that uses apache web server integrated with tomcat. As i acces any xhtml page in IE it opens the Save dialog box to save the file reather than display it. In FireFox it display the file but no XHTML tag is parsed. So i guess currently apache server is trying to serve xhtml itself rather than fwding to tomcat and XHTML extension is not recognized.

I need two things to configure:

1- Configure apache to foward .xhtml requests to tomcat
2- Configure tomcat to server .xhtml files

For first if added follwoing lines to .htaccess file ( i don't have access to httpd.conf in shared hosting)
AddType application/xhtml+xml .xhtml
AddHandler jserv-servlet .xhtml

but it does work. Could you please share you experience what configurations i need to make it work at both Apache server and application web.xml etc

Thanks
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14480
    
    7

I'm afraid you're making the common mistake of confusing URLs with resource paths. Normally you wouldn't have an ".xhtml" extension on the URLs (I use ".jsf") and therefore there is no need to configure Apache to understand ".xhtml".

In any event, referencing the ".xhtml" resource directly doesn't work. You have to submit a JSF URL or the request won't be routed through the FacesServlet and the JSF processes won't be invoked - all it will do is return the xhtml source.

Also, it looks like you're not properly configured in the apache-to-Tomcat connector, since if you were, Apache wouldn't care about the extension on the URL - it would route all matching URLs to Tomcat.


Customer surveys are for companies who didn't pay proper attention to begin with.
anyz mick
Greenhorn

Joined: Aug 09, 2004
Posts: 15
Thanks for your reply Tim.
Here is my FacesServlet mapping to serve xhtml in web.xml file:


and default suffix:


I do call xhtml files diretly e.g. http://myserver/myApp/login.xhtml.
I have links directly pointing to xhtml files. You are correct that FacesServlet is not capturing the xhtml URLs and source is returned back. But how can i fix it?
anyz mick
Greenhorn

Joined: Aug 09, 2004
Posts: 15
I am using JSF 1.2 with rich faces. I followed similar thread at http://www.coderanch.com/t/500479/JSF/java/JSF-Facelets but even URL like http://myserver/myapp/login.jsf not works. My FacesServlet is defined to catch *.xhtml. And its working perfect on Tomcat. Not getting it up on my hosting that has Apache server at front and integrated with Tocmat.

 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: JSF application on Apacher web server and Tomcat
 
Similar Threads
Servers
My *.jsp files will not execute unless in /servlet path.
Configuring Apache with Tomcat
File upload to a different url than hosting server
How does Mod_JK connector work?