tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: JSP pages are not loaded. Only HTML source code
Date Thu, 10 Mar 2011 17:52:53 GMT
Petr Hracek wrote:
> Thank you for explanation for me.
> How can be handled ProxyPassReverse for case
> ProxyPassMatch ^/XYtest/servlet/(.*)$  ajp://localhost:8009/XYtest/$1
> Is it enough to have ProxyPassReversy /XYtest/servlet
> ajp://localhost:8009/XYtest/servlet

With the above configuration, use

ProxyPassReverse /XYtest/servlet

For more info :

When everything so far is working, then save that configuration, and I will give you a new

and simpler configuration, below the line


It is often easier to have all of the files of one application together, instead of in 
different directories. You just have to be careful that by doing so, you do not create a 
security hole.

At this moment, you have the "Apache stuff" in
and the "Tomcat stuff" in

If (*) the "Apache stuff" is only html pages, stylesheets, javascript libraries, images 
and so on, then you can put everything back together, and let it all be served by Tomcat.
Tomcat can act as a "normal" HTTP server, just like Apache, and it can serve these files 
as well and as fast as Apache httpd.

So, for example :
1) copy all that you have under /opt/test/htdocs/*, into /opt/test/servlet/*
2) delete /opt/test/htdocs/
3) in the Apache configuration file, change the proxy instructions as follows :

ProxyPass /XYtest ajp://localhost:8009/XYTest
ProxyPassReverse /XYtest ajp://localhost:8009/XYTest

3) in your index.html, leave the src elements like this :

<frame src="/XyTest/jsp/Viewer/View.jsp" ...

So now what will happen ?

For every request for a URL that starts with "/XYtest", Apache will forward the request to

Tomcat will receive the request, and will direct it to your application XYtest.
- If it is a request for a file inside of "/opt/test/servlet/WEB-INF/", Tomcat will return

an error (Forbidden).
- if it is a request for a JSP page, Tomcat will process it correctly, using your JSP 
"servlets" (the ones resulting from the compilation of the JSP pages)
- if it is a request for something else (like a static html page, or a .css or a .js 
file), Tomcat will process it with the default servlet, which simply returns the file 
(like Apache httpd would do it).

There is no security problem, because Apache sends everything starting with "/XYtest" to 
Tomcat, and Tomcat knows what to return and what not.
The point is, in this case you are not allowing Apache to "bypass" Tomcat and serve the 
files from WEB-INF directly.

(*) The reason for the "if" above, is that there can be a reason not to do that.
Tomcat can serve Java applications (servlets, JSP pages) very well. That's its basic 
function.  It can also serve static files well (html pages, images, etc..).
But what Tomcat does less well than Apache, is process cgi-bin scripts (e.g. in perl or PHP).
So, if your application contains also cgi-bin scripts, or PHP pages, then I would not do 
the above, and I would keep them separate.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message