• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

After I've configured Apache+Tomcat, WEB-INF cannot be accessed from JSP

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello!

I am having a situation which I cannot understand and resolve.

I have configured Apache+mod_jk+Tomcat. Apache Web server hosts PHP web sites only and Tomcat hosts JSP web sites only. Almost everything works well but jsp:include stoped working properly!!!


Using VirtualHosting I configured:

domain_1.com - is processed by Apache
domain_2.com - is processed by Tomcat(both static content and JSP/Servlets)

In domain_2.com JSP is working well, Servlets are working well. But jsp:include stoped working properly!!!

For example:
index.jsp includes siteMenu.jsp

<jsp:include page="WEB-INF/siteMenu.jsp"/>----- this works well!

but other pages located in subfolders cannot access WEB-INF

<jsp:include page="../WEB-INF/siteMenu.jsp"/>----- does not work. Cannot find the file..
and
<jsp:include page="/WEB-INF/siteMenu.jsp"/>----- from subfolders does not work ....

But if I access web sites using Tomcat only - not via Apache and mod_jk, then the Web site is working properly and all pages are included properly. No code modification needed.

Please advised me what did I configure wrong? How to fix this?


#worker.properties file
workers.tomcat_home=/mnt/ebs/apache-tomcat-6.0.14
workers.java_home=/usr/java/jdk1.6.0_21
worker.list=ajp13

worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13

#server.xml

<Host name="www.domain_2.com" appBase="webapps/domain2"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="/" docBase="/mnt/ebs/apache-tomcat-6.0.14/webapps/domain2"/>
</Host>


# Configure mod_jk in httpd.conf
#
LoadModule jk_module /etc/httpd/modules/mod_jk.so
JkWorkersFile /mnt/ebs/apache-tomcat-6.0.14/conf/worker.properties
<VirtualHost *>
DocumentRoot "/mnt/ebs/apache-tomcat-6.0.14/webapps/domain2"
ServerName "www.domain_2.com"
DirectoryIndex index.jsp
JkMount /* ajp13
</VirtualHost>

Thank you!

 
Sergey Kargopolov
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tried using ajp instead of mod_jk to see the difference and now I am getting an error message:

You do not have permission to access / on this server

<VirtualHost *>
DocumentRoot "TOMCAT/webapps/domain_2"
ServerName "www.domain2.com"
DirectoryIndex index.jsp
ProxyPreserveHost On

ProxyPass /* ajp://localhost:8009
ProxyPassReverse /* ajp://localhost:8009

<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>
 
Sergey Kargopolov
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Has anyone come across this situation? please advise me... Where is mistake? What do i do wrong? I read Tomcat 6 documentation and searched the web for examples of integration Apache with Tomcat and it looks to me that I did the integration correctly. If the above mentioned configuration is correct then why would JSP be not able to include other JSP pages from upper directories?

I double checked!!! If I use mod_jk and Apache as front server then JSP can include any other JSP pages from sub directories. But cannot include any other JSP from upper directories.

<jsp:include page="WEB-INF/siteMenu.jsp"/>----- this works well!
<jsp:include page="inc/siteMenu.jsp"/>----- this works well!

<jsp:include page="/WEB-INF/siteMenu.jsp"/>----- does not work!
<jsp:include page="../WEB-INF/siteMenu.jsp"/>-----does not work!
<jsp:include page="../inc/siteMenu.jsp"/>-----does not work!

But if I access JSP web application with Tomcat as Stand along then jsp:include works properly and no problems appear.

Please advise me how to resolve this situation.?

Thank you!

Thank you.
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This almost definitely has to do with a path issue. You think the relative URI is coming from the File Path, so "/WEB-INF/" would mean '/mnt/ebs/apache-tomcat-6.0.14/webapps/domain2/WEB-INF/' but it is likely coming from the web URL, 'http://www.domain_1.com/WEB-INF/'. So when you try to use the JSP include, don't do it relative to the file you are at, but do it relative to the URL the browser is at. See if that helps.
 
Sergey Kargopolov
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Steve!

Thank you very much for your reply!

What you are suggesting makes perfect sense. Here is what I have tried. Please have a look if I am getting you correctly.

The location of the page that includes "siteMenu.jsp" is at www.doman2.com/photo/index.jsp

Here is what I've tried:

<jsp:include page="'/mnt/ebs/apache-tomcat-6.0.14/webapps/domain2/WEB-INF/inc/siteMenu.jsp"/> -- Does not work
<jsp:include page="http://www.domain2.com/WEB-INF/inc/siteMenu.jsp"/> -- Does not work

Then I tried using @ include and got an error message:

<%@ include file="../WEB-INF/inc/siteMenu.jsp" %>

org.apache.jasper.JasperException: /photoView.jsp(61,3) File "/../WEB-INF/inc/siteMenu.jsp" not found


Steve, what am I doing wrong?


 
Steve Luke
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<jsp:include page="http://www.domain2.com/WEB-INF/inc/siteMenu.jsp"/>

This is the route you will probably have to take. The problem is that you can not access the WEB-INF directory outside the web app it belongs to. What happens when you move the /inc/siteMenu.jsp out of the WEB-INF and into the base directory (or some non-WEB-INF subdirectory)

Something like
<jsp:include page="http://www.domain2.com/menus/inc/siteMenu.jsp"/>



I am actually out of my league at this point though. I think this is correct, but it has been over a year since I have touched a web application...
 
Sergey Kargopolov
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have tried that Steve!

In fact when I move the siteMenu.jsp to the same directory level as pages that include it or into a subdirectory then <jsp:include> works properly.

So, if I make a copy of siteMenu.jsp and place it on the same directory level then this works!

<jsp:include page="siteMenu.jsp"/>

When I move siteMenu.jsp into a subdirectory then it also works!

<jsp:include page="inc/siteMenu.jsp"/>

but when I place siteMenu.jsp to an upper level directory then it stops working...

<jsp:include page="../inc/siteMenu.jsp"/> or <jsp:include page="/inc/siteMenu.jsp"/> do not work!


I need siteMenu.jsp to be located in one upper directory or WEB-INF so that any page of web application can access it from any directory.

This behavior is only when requests are directed to JSP web application via Apache mod_jk. If I open web application in Tomcat as Stand along container/web server. Then jsp:include works properly and includes files from upper or lower level directories no problem.

Any thoughts?

 
Blood pressure normal? What do I change to get "magnificent"? Maybe this tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic