You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Petr Hracek <ph...@gmail.com> on 2011/03/08 10:49:44 UTC
JSP pages are not loaded. Only HTML source code
Dear users,
I would like to asked you on the some thing regarding JSP pages.
On the Linux whereis installed apache 2.2.14 and tomcat 5.5.28 I would
like to run
JSP pages.
JSP pages should be run over mod_proxy_ajp.
URL is:
http://<IP_address>/XYtest/jsp/Viewer/index.html
ProxyPass /XYtest/*.jsp ajp://localhost:8009/XYtest
ProxyPassReverse /XYtest/*.jsp ajp://localhost:8009/XYtest
JSP page is called from HTML (index.html) and FRAME src "view.jsp"
mentioned above.
but instead of showing JSP page HTML source code is shown.
Do you know what could be a reason?
in the Catalina configuration directory
(/etc/tomcat5/base/Catalina/localhost/XYtest.xml) is following context
file
test# cat /etc/tomcat/5/base/Catalina/locahost/XYtest.xml
<?xml version='1.0' encoding='utf-8'?>
<Context docBase="/opt/test/XYtest" allowLinking="true">
</Context>
test#
structure in Linux is:
/opt/test/XYtest/jsp/Viewer where are located files index.html and
view.jsp which is part of FRAME
--
Best Regards / S pozdravem
Petr Hracek
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: JSP pages are not loaded. Only HTML source code
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Patr,
On 3/8/2011 5:37 AM, Petr Hracek wrote:
> Structure of the document is following:
> index.html
> <frameset rows="63,40,*" frameborder="0">
> <frame src="logo.html" name="logo" noresize scrolling="no"
> marginwidth="0" marginheight="
> 0">
> <frame src="View.jsp" name="toolbar" noresize scrolling="no"
> marginwidth="0" marginhei
> ght="0">
> <frame src="View2.jsp" name="ctrl">
> </frameset>
>
> Sorry for wrong explanation.
> I hope that this is correct.
Is the above document the one showing only the source instead of
actually rendering? Or, is the above document loading "View.jsp" which
shows it's JSP source code. Or, is "View.jsp" running and producing pure
HTML, and then showing the raw HTML?
Usually when things like this happen, it's because the server is
sending-back the wrong content type with the response. The content type
should be text/html (or something similar).
What web browser are you using? What does it report for the content type
of the document you're viewing?
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk12QFYACgkQ9CaO5/Lv0PDtGQCbBF/SAJzypMrk8+/EQym9aqAR
VtYAoLA5EkAX9/QNgBtL6N2H5Bi8Tr8w
=lFqy
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: JSP pages are not loaded. Only HTML source code
Posted by Petr Hracek <ph...@gmail.com>.
Structure of the document is following:
index.html
<frameset rows="63,40,*" frameborder="0">
<frame src="logo.html" name="logo" noresize scrolling="no"
marginwidth="0" marginheight="
0">
<frame src="View.jsp" name="toolbar" noresize scrolling="no"
marginwidth="0" marginhei
ght="0">
<frame src="View2.jsp" name="ctrl">
</frameset>
Sorry for wrong explanation.
I hope that this is correct.
2011/3/8 Zbynek Vavros <Zb...@cz.ibm.com>:
>
> Dear user,
>
> are you sure using JSP inside HTML is good idea?
> JSPs are going to be translated into servlet anyway and HTML will not :)
> Cant you use JSP inside JSP?
>
> Zbynek
>
> Kind Regards / Mit
> freundlichen Grüßen /
> Üdvözlettel / S
> pozdravem:
>
>
> Zbynek VAVROS (Embedded
> Development image moved
> to file:
> pic22417.gif)
>
> Delivery Centre 616 00, Brno
> Central Europe Technicka 21
> Brno SITE Czech Republic
>
> (Embedded image moved to
> file: pic27057.gif) Phone: 420-53341- x6283
> Mobile:
> E-mail: Zbynek_Vavros@cz.ibm.com
>
>
>
>
> IBM Global Services
> Delivery Center Czech
> Republic, s.r.o.
> Registered address:
> Brno, Technicka 2995/21,
> Zip code: 61600, Company
> ID: 26244535
> Entered in the
> Commercial Register
> maintained by the
> Regional Court in Brno
> (Part C, Entry 39922)
>
> IBM Global Services
> Delivery Center Czech
> Republic, s.r.o.
> Sídlo: Brno, Technická
> 2995/21, PSČ 61600 IČ:
> 26244535
> Zapsaná v obchodním
> rejstříku, vedeném
> Krajským soudem v Brně
> oddíl C, vlozka 39922
>
>
>
>
>
>
> |------------>
> | From: |
> |------------>
> >--------------------------------------------------------------------------------------------------------------------------------------------------|
> |Petr Hracek <ph...@gmail.com> |
> >--------------------------------------------------------------------------------------------------------------------------------------------------|
> |------------>
> | To: |
> |------------>
> >--------------------------------------------------------------------------------------------------------------------------------------------------|
> |Tomcat Users List <us...@tomcat.apache.org> |
> >--------------------------------------------------------------------------------------------------------------------------------------------------|
> |------------>
> | Date: |
> |------------>
> >--------------------------------------------------------------------------------------------------------------------------------------------------|
> |03/08/2011 10:50 AM |
> >--------------------------------------------------------------------------------------------------------------------------------------------------|
> |------------>
> | Subject: |
> |------------>
> >--------------------------------------------------------------------------------------------------------------------------------------------------|
> |JSP pages are not loaded. Only HTML source code |
> >--------------------------------------------------------------------------------------------------------------------------------------------------|
>
>
>
>
>
> Dear users,
>
> I would like to asked you on the some thing regarding JSP pages.
> On the Linux whereis installed apache 2.2.14 and tomcat 5.5.28 I would
> like to run
> JSP pages.
> JSP pages should be run over mod_proxy_ajp.
> URL is:
> http://<IP_address>/XYtest/jsp/Viewer/index.html
> ProxyPass /XYtest/*.jsp ajp://localhost:8009/XYtest
> ProxyPassReverse /XYtest/*.jsp ajp://localhost:8009/XYtest
>
> JSP page is called from HTML (index.html) and FRAME src "view.jsp"
> mentioned above.
> but instead of showing JSP page HTML source code is shown.
>
> Do you know what could be a reason?
> in the Catalina configuration directory
> (/etc/tomcat5/base/Catalina/localhost/XYtest.xml) is following context
> file
> test# cat /etc/tomcat/5/base/Catalina/locahost/XYtest.xml
> <?xml version='1.0' encoding='utf-8'?>
> <Context docBase="/opt/test/XYtest" allowLinking="true">
> </Context>
> test#
>
> structure in Linux is:
> /opt/test/XYtest/jsp/Viewer where are located files index.html and
> view.jsp which is part of FRAME
>
> --
> Best Regards / S pozdravem
> Petr Hracek
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
--
Best Regards / S pozdravem
Petr Hracek
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: JSP pages are not loaded. Only HTML source code
Posted by Zbynek Vavros <Zb...@cz.ibm.com>.
Dear user,
are you sure using JSP inside HTML is good idea?
JSPs are going to be translated into servlet anyway and HTML will not :)
Cant you use JSP inside JSP?
Zbynek
Kind Regards / Mit
freundlichen Grüßen /
Üdvözlettel / S
pozdravem:
Zbynek VAVROS (Embedded
Development image moved
to file:
pic22417.gif)
Delivery Centre 616 00, Brno
Central Europe Technicka 21
Brno SITE Czech Republic
(Embedded image moved to
file: pic27057.gif) Phone: 420-53341- x6283
Mobile:
E-mail: Zbynek_Vavros@cz.ibm.com
IBM Global Services
Delivery Center Czech
Republic, s.r.o.
Registered address:
Brno, Technicka 2995/21,
Zip code: 61600, Company
ID: 26244535
Entered in the
Commercial Register
maintained by the
Regional Court in Brno
(Part C, Entry 39922)
IBM Global Services
Delivery Center Czech
Republic, s.r.o.
Sídlo: Brno, Technická
2995/21, PSČ 61600 IČ:
26244535
Zapsaná v obchodním
rejstříku, vedeném
Krajským soudem v Brně
oddíl C, vlozka 39922
|------------>
| From: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|Petr Hracek <ph...@gmail.com> |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| To: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|Tomcat Users List <us...@tomcat.apache.org> |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Date: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|03/08/2011 10:50 AM |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Subject: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|JSP pages are not loaded. Only HTML source code |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
Dear users,
I would like to asked you on the some thing regarding JSP pages.
On the Linux whereis installed apache 2.2.14 and tomcat 5.5.28 I would
like to run
JSP pages.
JSP pages should be run over mod_proxy_ajp.
URL is:
http://<IP_address>/XYtest/jsp/Viewer/index.html
ProxyPass /XYtest/*.jsp ajp://localhost:8009/XYtest
ProxyPassReverse /XYtest/*.jsp ajp://localhost:8009/XYtest
JSP page is called from HTML (index.html) and FRAME src "view.jsp"
mentioned above.
but instead of showing JSP page HTML source code is shown.
Do you know what could be a reason?
in the Catalina configuration directory
(/etc/tomcat5/base/Catalina/localhost/XYtest.xml) is following context
file
test# cat /etc/tomcat/5/base/Catalina/locahost/XYtest.xml
<?xml version='1.0' encoding='utf-8'?>
<Context docBase="/opt/test/XYtest" allowLinking="true">
</Context>
test#
structure in Linux is:
/opt/test/XYtest/jsp/Viewer where are located files index.html and
view.jsp which is part of FRAME
--
Best Regards / S pozdravem
Petr Hracek
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: JSP pages are not loaded. Only HTML source code
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Christopher Schultz [mailto:chris@christopherschultz.net]
> Subject: Re: JSP pages are not loaded. Only HTML source code
> > XYtest.xml is now:
> > <?xml version='1.0' encoding='utf-8'?>
> > <Context docBase="/opt/test/servlet" allowLinking="true">
> > </Context>
> Try removing all the "/servlet" references from your configurations
> and URLs (except for your docBase: that needs to stay) and see if
> that helps things.
Might be useful to see the directory structure *under* /opt/test/servlet to make sure it in any way resembles that required for a webapp...
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
Re: JSP pages are not loaded. Only HTML source code
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Petr,
On 3/9/2011 9:49 AM, Petr Hracek wrote:
> You mean that in HTML file I should remove servlet?
I think you have a lot of things confused, here. I'm going to pick and
choose from your previous posts and address a few of the things I think
are standing in your way.
> Is this web.xml file correct?
Maybe.
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <!DOCTYPE web-app
> PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
> "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
Servlet 2.2 is so old I don't even want to look up it's age. If you are
writing a new webapp, you should be targeting the 3.0 spec.
> <web-app>
> <display-name>Viewer</display-name>
>
> <jsp-property-group>
> <url-pattern>/jsp/Viewer/*.jsp</url-pattern>
> </jsp-property-group>
I don't think you need a jsp-property-group unless you intend to do
something with it: you have specified no properties, so why bother
defining the group?
> <jsp-config>
> <taglib>
> <taglib-uri>http://java.sun.com/jstl/core-rt</taglib-uri>
> <taglib-location>/WEB-INF/c-rt.tld</taglib-location>
> </taglib>
> <taglib>
> <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
> <taglib-location>/WEB-INF/c.tld</taglib-location>
> </taglib>
> </jsp-config>
I believe Tomcat will scan your webapp's libraries for taglib files
unless you tell it not to -- that may be sensitive to the servlet spec
version you specify in your web.xml file. Updating to the latest spec
will likely reduce the amount of stuff you have to specify in web.xml,
such as the above.
> XYtest.xml is now:
> <?xml version='1.0' encoding='utf-8'?>
> <Context docBase="/opt/test/servlet" allowLinking="true">
> </Context>
Your webapp is stored in /opt/test/servlet, and your webapp's name is
XYtest (inherited from the .xml file name) so all URLs should be like
this "/XYtest".
> And jsp are stored in
> /opt/test/servlet/jsp/Viewer/View.jsp
So a fully-qualified URL for that JSP would be
http://host/XYtest/jsp/Viewer/View.jsp
> <frame src="/XYtest/servlet/jsp/Viewer/View.jsp"
... so the "servlet" is problematic: remove it.
> ProxyPass /XYtest/servlet ajp://localhost:8009/XYtest/servlet
> ProxyPassReverse /XYtest/servlet ajp://localhost:8009/XYtest/servlet
Generally speaking, it's best to map your webapp's URI space direct into
Tomcat, like this:
> ProxyPass /XYtest ajp://localhost:8009/XYtest
I guess you just copied the "servlet" over from your URIs in other
places. Try the above and see if it helps.
> What is wrong?
> Other servlets which did not used JSP are working properly.
I can't decide if I'm surprised that your servlets worked while your
JSPs didn't, or if it makes perfect sense... let's try to get some other
things sorted-out, first.
Try removing all the "/servlet" references from your configurations and
URLs (except for your docBase: that needs to stay) and see if that helps
things.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk13qrYACgkQ9CaO5/Lv0PBqAACfVe7bj5gYTvLzzyTE1x6+MOvp
pDoAoIbxafNCLZODOZv5Vv5RTAcKldME
=thw2
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: JSP pages are not loaded. Only HTML source code
Posted by André Warnier <aw...@ice-sa.com>.
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
ajp://localhost:8009/XYtest
For more info :
http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassreverse
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
/opt/test/htdocs
and the "Tomcat stuff" in
/opt/test/servlet
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.
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: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: JSP pages are not loaded. Only HTML source code
Posted by Petr Hracek <ph...@gmail.com>.
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
Directory structure in servlet directory is:
/opt/test/servlet/WEB-INF
/opt/test/servlet/WEB-INF/lib and jar files
/opt/test/servlet/WEB-INF/web.xml
/opt/test/servlet/WEB-INF/c-rt.tld
/opt/test/servlet/WEB-INF/c.tld
/opt/test/servlet/jsp/Viewer/View.jsp
web.xml file is following:
<web-app>
<display-name>MIB Viewer</display-name>
<jsp-config>
<taglib>
<taglib-uri>http://java.sun.com/jstl/core-rt</taglib-uri>
<taglib-location>/WEB-INF/c-rt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://www.pse.siemens.com/unity/nbcs</taglib-uri>
<taglib-location>/WEB-INF/nbcs.tld</taglib-location>
</taglib>
</jsp-config>
</web-app>
Thank you in advance
2011/3/9 André Warnier <aw...@ice-sa.com>:
> Mark Thomas wrote:
>>
>> On 09/03/2011 16:02, André Warnier wrote:
>>>
>>> Now from the train..
>>>
>>> When you request a URL such as this from Tomcat :
>>>
>>> (http://hostname)/ABC/DEF/hij.jsp
>>>
>>> Tomcat uses the first component of the path (/ABC) as mapping for the
>>> "web application".
>>> It then passes the request to the application "ABC".
>>
>> Not strictly correct.
>>
>> Tomcat compares the URL to the list of context paths and the longest
>> match wins.
>>
>> In the example above the context path may be any of the following:
>> /
>> /ABC
>> /ABC/DEF
>> you simply can't tell from looking at the URL. You have to know what
>> context paths are currently configured.
>>
>
> That is certainly more correct than my simplified explanation,
> but,at this point, likely to confuse the OP a bit more, maybe ?
>
> Quoting selectively from Petr's previous posts :
> ...
> in the Catalina configuration directory
> (/etc/tomcat5/base/Catalina/localhost/XYtest.xml) is following context
>
> ...
> (now)
> Apache things are in directory
> /opt/test/htdocs
> tomcat things are in directory
> /opt/test/servlet
>
> (/etc/tomcat5/base/Catalina/localhost/)XYtest.xml is now:
> <?xml version='1.0' encoding='utf-8'?>
> <Context docBase="/opt/test/servlet" allowLinking="true">
> </Context>
>
> And jsp are stored in
> /opt/test/servlet/jsp/Viewer/View.jsp
> ...
>
> end quote
>
> and he didn't say -- but I presume --, that web.xml is in
> /opt/test/servlet/WEB-INF/web.xml
>
>
> So, Petr, to bring all this together :
>
> 1) in /etc/tomcat5/base/Catalina/localhost/XYtest.xml :
>
> docBase="/opt/test/servlet"
>
> 2) in the Apache config :
>
> ProxyPassMatch ^/XYtest/(.*\.jsp)$ ajp://localhost:8009/XYtest/$1
>
> Because if you just use
> ProxyPass /XYtest ajp://localhost:8009/Xytest
> then a URL like "/XYtest/index.html" will also be passed to Tomcat, and
> Tomcat will not find it, considering the location of your "Apache things"
> above.
>
> 3) in the file index.html :
> <frame src="/XyTest/jsp/Viewer/View.jsp" ...
>
> Alternatively, you could do :
>
> 1a) in /etc/tomcat5/base/Catalina/localhost/XYtest.xml :
>
> docBase="/opt/test/servlet"
>
> 2a) in the Apache config :
>
> ProxyPassMatch ^/XYtest/servlet/(.*)$ ajp://localhost:8009/XYtest/$1
>
> 3a) in the file index.html :
> <frame src="/XyTest/servlet/jsp/Viewer/View.jsp" ...
>
> (in this case, the ProxyPassMatch directive will "strip" the "/servlet"
> part, which confuses Tomcat)
>
>
> When (if?) the above is working, then I will suggest a better (and simpler)
> layout
> for the files and directives.
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
--
Best Regards / S pozdravem
Petr Hracek
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: JSP pages are not loaded. Only HTML source code
Posted by André Warnier <aw...@ice-sa.com>.
Mark Thomas wrote:
> On 09/03/2011 16:02, André Warnier wrote:
>> Now from the train..
>>
>> When you request a URL such as this from Tomcat :
>>
>> (http://hostname)/ABC/DEF/hij.jsp
>>
>> Tomcat uses the first component of the path (/ABC) as mapping for the
>> "web application".
>> It then passes the request to the application "ABC".
>
> Not strictly correct.
>
> Tomcat compares the URL to the list of context paths and the longest
> match wins.
>
> In the example above the context path may be any of the following:
> /
> /ABC
> /ABC/DEF
> you simply can't tell from looking at the URL. You have to know what
> context paths are currently configured.
>
That is certainly more correct than my simplified explanation,
but,at this point, likely to confuse the OP a bit more, maybe ?
Quoting selectively from Petr's previous posts :
...
in the Catalina configuration directory
(/etc/tomcat5/base/Catalina/localhost/XYtest.xml) is following context
...
(now)
Apache things are in directory
/opt/test/htdocs
tomcat things are in directory
/opt/test/servlet
(/etc/tomcat5/base/Catalina/localhost/)XYtest.xml is now:
<?xml version='1.0' encoding='utf-8'?>
<Context docBase="/opt/test/servlet" allowLinking="true">
</Context>
And jsp are stored in
/opt/test/servlet/jsp/Viewer/View.jsp
...
end quote
and he didn't say -- but I presume --, that web.xml is in
/opt/test/servlet/WEB-INF/web.xml
So, Petr, to bring all this together :
1) in /etc/tomcat5/base/Catalina/localhost/XYtest.xml :
docBase="/opt/test/servlet"
2) in the Apache config :
ProxyPassMatch ^/XYtest/(.*\.jsp)$ ajp://localhost:8009/XYtest/$1
Because if you just use
ProxyPass /XYtest ajp://localhost:8009/Xytest
then a URL like "/XYtest/index.html" will also be passed to Tomcat, and Tomcat will not
find it, considering the location of your "Apache things" above.
3) in the file index.html :
<frame src="/XyTest/jsp/Viewer/View.jsp" ...
Alternatively, you could do :
1a) in /etc/tomcat5/base/Catalina/localhost/XYtest.xml :
docBase="/opt/test/servlet"
2a) in the Apache config :
ProxyPassMatch ^/XYtest/servlet/(.*)$ ajp://localhost:8009/XYtest/$1
3a) in the file index.html :
<frame src="/XyTest/servlet/jsp/Viewer/View.jsp" ...
(in this case, the ProxyPassMatch directive will "strip" the "/servlet" part, which
confuses Tomcat)
When (if?) the above is working, then I will suggest a better (and simpler) layout
for the files and directives.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: JSP pages are not loaded. Only HTML source code
Posted by Mark Thomas <ma...@apache.org>.
On 09/03/2011 16:02, André Warnier wrote:
> Now from the train..
>
> When you request a URL such as this from Tomcat :
>
> (http://hostname)/ABC/DEF/hij.jsp
>
> Tomcat uses the first component of the path (/ABC) as mapping for the
> "web application".
> It then passes the request to the application "ABC".
Not strictly correct.
Tomcat compares the URL to the list of context paths and the longest
match wins.
In the example above the context path may be any of the following:
/
/ABC
/ABC/DEF
you simply can't tell from looking at the URL. You have to know what
context paths are currently configured.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: JSP pages are not loaded. Only HTML source code
Posted by André Warnier <aw...@ice-sa.com>.
Now from the train..
When you request a URL such as this from Tomcat :
(http://hostname)/ABC/DEF/hij.jsp
Tomcat uses the first component of the path (/ABC) as mapping for the "web application".
It then passes the request to the application "ABC".
*Within* that application, there are servlets or jsp pages (or any other file).
If that application contains a "WEB-INF/web.xml" file, Tomcat will look there for specific
mappings *within* the application.
That means, that it will remove the first component of the path (the one used to select
the application, such as "/ABC" above), and try to match the rest with a <url-pattern> tag.
So in this case, it will try to match "/DEF/hij.jsp".
If it finds a match, then it will pass the request to the corresponding servlet (or
compiled jsp page, which internally is the same).
If it does not find a match, then it will pass the request to the "default servlet", which
is implicitly part of every web application, and which handles basically static content
(like html pages e.g.).
What I am saying is that you must make sure that the URLs which you pass to Tomcat conform
to this mechanism.
If you pass to Tomcat a URL like :
http://yourhost/XYtest/servlet/jsp/Viewer/Viewer.jsp
then Tomcat is going to :
- use "/XYtest" to select the web application. In your case, that leads to the application
"XYtest", whose "top" is in the directory /opt/test/servlet.
- then it will strip the "/XYtest" part, and in the file /opt/test/servlet/WEB-INF/web.xml
it will look for a URL pattern matching the rest, which is "/servlet/jsp/Viewer/Viewer.jsp".
Do you have a url-pattern matching this in the web.xml file ?
No. You only have a pattern "/jsp/Viewer/*.jsp".
So something is wrong...
Instead of
<frame src="/XYtest/servlet/jsp/Viewer/View.jsp" ...
you should probably be using
<frame src="/XYtest/jsp/Viewer/View.jsp"
That is what I meant when saying that you have a "servlet" too many somewhere.
Of course, make sure that your proxy statements in Apache still match this new URL.
Petr Hracek wrote:
> You mean that in HTML file I should remove servlet?
>
> Is this web.xml file correct?
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <!DOCTYPE web-app
> PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
> "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
>
> <web-app>
> <display-name>Viewer</display-name>
>
> <jsp-property-group>
> <url-pattern>/jsp/Viewer/*.jsp</url-pattern>
> </jsp-property-group>
> <jsp-config>
> <taglib>
> <taglib-uri>http://java.sun.com/jstl/core-rt</taglib-uri>
> <taglib-location>/WEB-INF/c-rt.tld</taglib-location>
> </taglib>
> <taglib>
> <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
> <taglib-location>/WEB-INF/c.tld</taglib-location>
> </taglib>
> </jsp-config>
> </web-app>
>
> best regards
> Petr
> 2011/3/9 André Warnier <aw...@ice-sa.com>:
>> Quickly, because I have to get a train..
>>
>> I think that this :
>>
>> <Context docBase="/opt/test/servlet" allowLinking="true">
>>
>> togethet with this :
>>
>> <frame src="/XYtest/servlet/jsp/Viewer/View.jsp"
>>
>> is wrong. You have a "servlet" too many there.
>> In other words,
>>
>> "/XYtest/" already points to "/opt/test/servlet".
>> If you say "/XYtest/servlet/x", you are pointing to
>> "/opt/test/servlet/servlet/x", no ?
>>
>>
>>
>>
>>
>>
>>
>> Petr Hracek wrote:
>>> I have changed sources so that the actuall state is following:
>>>
>>> Apache things are in directory
>>> /opt/test/htdocs
>>> tomcat things are in directory
>>> /opt/test/servlet
>>>
>>> XYtest.xml is now:
>>> <?xml version='1.0' encoding='utf-8'?>
>>> <Context docBase="/opt/test/servlet" allowLinking="true">
>>> </Context>
>>>
>>> And jsp are stored in
>>> /opt/test/servlet/jsp/Viewer/View.jsp
>>>
>>> Updated HTML file stored in /opt/test/htdocs is:
>>> <frameset rows="63,40,*" frameborder="0">
>>> <frame src="logo.html" name="logo" noresize scrolling="no"
>>> marginwidth="0" marginheight="
>>> 0">
>>> <frame src="/XYtest/servlet/jsp/Viewer/View.jsp" name="toolbar"
>>> noresize scrolling="no"
>>> marginwidth="0" marginhei
>>> ght="0">
>>> <frame src="/XYtest/servlet/jsp/Viewer/View2.jsp" name="ctrl">
>>> </frameset>
>>>
>>> Apache has been updated accordingly:
>>> ProxyPass /XYtest/servlet ajp://localhost:8009/XYtest/servlet
>>> ProxyPassReverse /XYtest/servlet ajp://localhost:8009/XYtest/servlet
>>>
>>> Unfortunatelly it shows me: HTTP 404
>>>
>>> message /XYtest/servlet/jsp/Viewer/View.jsp
>>>
>>> description The requested resource
>>> (/XYtest/servlet/jsp/Viewer/View.jsp) is not available.
>>>
>>> What is wrong?
>>> Other servlets which did not used JSP are working properly.
>>>
>>> Thank you in advance
>>> Petr
>>>
>>>
>>> 2011/3/8 André Warnier <aw...@ice-sa.com>:
>>>> Petr Hracek wrote:
>>>>> Dear users,
>>>>>
>>>>> I would like to asked you on the some thing regarding JSP pages.
>>>>> On the Linux whereis installed apache 2.2.14 and tomcat 5.5.28
>>>> that's an old version of Tomcat. You should be using at least a 6.0.x
>>>> version by now.
>>>>
>>>> I would
>>>>> like to run
>>>>> JSP pages.
>>>>> JSP pages should be run over mod_proxy_ajp.
>>>>> URL is:
>>>>> http://<IP_address>/XYtest/jsp/Viewer/index.html
>>>>> ProxyPass /XYtest/*.jsp ajp://localhost:8009/XYtest
>>>>> ProxyPassReverse /XYtest/*.jsp ajp://localhost:8009/XYtest
>>>>>
>>>>> JSP page is called from HTML (index.html) and FRAME src "view.jsp"
>>>>> mentioned above.
>>>>> but instead of showing JSP page HTML source code is shown.
>>>>>
>>>>> Do you know what could be a reason?
>>>>> in the Catalina configuration directory
>>>>> (/etc/tomcat5/base/Catalina/localhost/XYtest.xml) is following context
>>>>> file
>>>>> test# cat /etc/tomcat/5/base/Catalina/locahost/XYtest.xml
>>>>> <?xml version='1.0' encoding='utf-8'?>
>>>>> <Context docBase="/opt/test/XYtest" allowLinking="true">
>>>>> </Context>
>>>>> test#
>>>>>
>>>>> structure in Linux is:
>>>>> /opt/test/XYtest/jsp/Viewer where are located files index.html and
>>>>> view.jsp which is part of FRAME
>>>>>
>>>> As a general observation : it looks like you are trying to serve the same
>>>> directory from Apache httpd and from Tomcat. That is generally a quite
>>>> bad
>>>> idea in terms of security, and also in terms of confusion, as you are
>>>> experiencing here.
>>>>
>>>> To understand what is happening, you must look at it from the browser
>>>> point
>>>> of view.
>>>>
>>>> Step 1 :
>>>>
>>>> Your initial html document "index.html" is :
>>>>
>>>> <frameset rows="63,40,*" frameborder="0">
>>>> <frame src="logo.html" name="logo" noresize scrolling="no"
>>>> marginwidth="0" marginheight="
>>>> 0">
>>>> <frame src="View.jsp" name="toolbar" noresize scrolling="no"
>>>> marginwidth="0" marginhei
>>>> ght="0">
>>>> <frame src="View2.jsp" name="ctrl">
>>>> </frameset>
>>>>
>>>> and the browser loads it from the URL :
>>>> http://<IP_address>/XYtest/jsp/Viewer/index.html
>>>>
>>>> Step 2 :
>>>>
>>>> In this document, the browser finds a reference to another document :
>>>>
>>>> <frame src="View.jsp" ..>
>>>>
>>>> The browser interprets that relative URL on the base of the origin of the
>>>> current page, and then it asks the server for that document.
>>>> So the browser requests the document (the inside frame) from the URL :
>>>> http://<IP_address>/XYtest/jsp/Viewer/View.jsp
>>>>
>>>> Step 3 :
>>>> The Apache httpd server receives the request for
>>>>
>>>> http://<IP_address>/XYtest/jsp/Viewer/View.jsp
>>>>
>>>> and it tries to match it with your proxy statement :
>>>>
>>>> ProxyPass /XYtest/*.jsp ajp://localhost:8009/XYtest
>>>>
>>>> It does not match (see below), so Apache httpd serves it itself, directly
>>>> from disk.
>>>> That is why you see the source : Tomcat never sees this request, and
>>>> Apache
>>>> has no idea that a ".jsp" file is anything else than text.
>>>>
>>>> Now why does it not match ?
>>>> Because the ProxyPass directive does not understand wildcards or regexp.
>>>> For that, you should us "ProxyPassMatch", for example like this :
>>>>
>>>> ProxyPassMatch "/XYtest/.*\.jsp$" ajp://localhost:8009/XYtest
>>>>
>>>> But it is still a bad idea.
>>>> Why ?
>>>>
>>>> Suppose that in the directory /opt/test/XYtest, there is a sub-directory
>>>> named "WEB-INF", and in that directory is a file "web.xml".
>>>> This file is a configuration file for your Tomcat web application, and it
>>>> may contain things like passwords for accessing a database for example.
>>>> For that reason (security), Tomcat /never/ allows a user to request a
>>>> document within the WEB-INF sub-directory of a web application.
>>>>
>>>> But with your setup, anyone can ask for the URL :
>>>> http://<IP_address>/XYtest/WEB-INF/web.xml
>>>>
>>>> and Apache httpd will happily return that file (also as a text file).
>>>> So, with you setup, you are bypassing an important security feature of
>>>> Tomcat, because you are allowing Apache httpd to go "around it".
>>>>
>>>> There are different possibilities to fix your configuration.
>>>> The first one would be to do this in Apache :
>>>>
>>>> ProxyPass /XYtest ajp://localhost:8009/XYtest
>>>>
>>>> and NOT define the directory /opt/test/XYtest in any way in Apache.
>>>> That way, any request for a URL starting will /XYtest will be forwarded
>>>> directly to Tomcat, and Tomcat will happily serve html pages (like
>>>> index.html) as well as Apache.
>>>> And it knows how to handle jsp pages too.
>>>>
>>>> Now, if all you want to do is serve html pages and jsp pages, you could
>>>> also
>>>> wonder if you need Apache httpd and mod_prox_ajp at all. You could set
>>>> Tomcat to answer directly on port 80, get rid of Apache httpd, and
>>>> simplify
>>>> your configuration.
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>
>>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: JSP pages are not loaded. Only HTML source code
Posted by Petr Hracek <ph...@gmail.com>.
You mean that in HTML file I should remove servlet?
Is this web.xml file correct?
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<display-name>Viewer</display-name>
<jsp-property-group>
<url-pattern>/jsp/Viewer/*.jsp</url-pattern>
</jsp-property-group>
<jsp-config>
<taglib>
<taglib-uri>http://java.sun.com/jstl/core-rt</taglib-uri>
<taglib-location>/WEB-INF/c-rt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>
</jsp-config>
</web-app>
best regards
Petr
2011/3/9 André Warnier <aw...@ice-sa.com>:
> Quickly, because I have to get a train..
>
> I think that this :
>
> <Context docBase="/opt/test/servlet" allowLinking="true">
>
> togethet with this :
>
> <frame src="/XYtest/servlet/jsp/Viewer/View.jsp"
>
> is wrong. You have a "servlet" too many there.
> In other words,
>
> "/XYtest/" already points to "/opt/test/servlet".
> If you say "/XYtest/servlet/x", you are pointing to
> "/opt/test/servlet/servlet/x", no ?
>
>
>
>
>
>
>
> Petr Hracek wrote:
>>
>> I have changed sources so that the actuall state is following:
>>
>> Apache things are in directory
>> /opt/test/htdocs
>> tomcat things are in directory
>> /opt/test/servlet
>>
>> XYtest.xml is now:
>> <?xml version='1.0' encoding='utf-8'?>
>> <Context docBase="/opt/test/servlet" allowLinking="true">
>> </Context>
>>
>> And jsp are stored in
>> /opt/test/servlet/jsp/Viewer/View.jsp
>>
>> Updated HTML file stored in /opt/test/htdocs is:
>> <frameset rows="63,40,*" frameborder="0">
>> <frame src="logo.html" name="logo" noresize scrolling="no"
>> marginwidth="0" marginheight="
>> 0">
>> <frame src="/XYtest/servlet/jsp/Viewer/View.jsp" name="toolbar"
>> noresize scrolling="no"
>> marginwidth="0" marginhei
>> ght="0">
>> <frame src="/XYtest/servlet/jsp/Viewer/View2.jsp" name="ctrl">
>> </frameset>
>>
>> Apache has been updated accordingly:
>> ProxyPass /XYtest/servlet ajp://localhost:8009/XYtest/servlet
>> ProxyPassReverse /XYtest/servlet ajp://localhost:8009/XYtest/servlet
>>
>> Unfortunatelly it shows me: HTTP 404
>>
>> message /XYtest/servlet/jsp/Viewer/View.jsp
>>
>> description The requested resource
>> (/XYtest/servlet/jsp/Viewer/View.jsp) is not available.
>>
>> What is wrong?
>> Other servlets which did not used JSP are working properly.
>>
>> Thank you in advance
>> Petr
>>
>>
>> 2011/3/8 André Warnier <aw...@ice-sa.com>:
>>>
>>> Petr Hracek wrote:
>>>>
>>>> Dear users,
>>>>
>>>> I would like to asked you on the some thing regarding JSP pages.
>>>> On the Linux whereis installed apache 2.2.14 and tomcat 5.5.28
>>>
>>> that's an old version of Tomcat. You should be using at least a 6.0.x
>>> version by now.
>>>
>>> I would
>>>>
>>>> like to run
>>>> JSP pages.
>>>> JSP pages should be run over mod_proxy_ajp.
>>>> URL is:
>>>> http://<IP_address>/XYtest/jsp/Viewer/index.html
>>>> ProxyPass /XYtest/*.jsp ajp://localhost:8009/XYtest
>>>> ProxyPassReverse /XYtest/*.jsp ajp://localhost:8009/XYtest
>>>>
>>>> JSP page is called from HTML (index.html) and FRAME src "view.jsp"
>>>> mentioned above.
>>>> but instead of showing JSP page HTML source code is shown.
>>>>
>>>> Do you know what could be a reason?
>>>> in the Catalina configuration directory
>>>> (/etc/tomcat5/base/Catalina/localhost/XYtest.xml) is following context
>>>> file
>>>> test# cat /etc/tomcat/5/base/Catalina/locahost/XYtest.xml
>>>> <?xml version='1.0' encoding='utf-8'?>
>>>> <Context docBase="/opt/test/XYtest" allowLinking="true">
>>>> </Context>
>>>> test#
>>>>
>>>> structure in Linux is:
>>>> /opt/test/XYtest/jsp/Viewer where are located files index.html and
>>>> view.jsp which is part of FRAME
>>>>
>>> As a general observation : it looks like you are trying to serve the same
>>> directory from Apache httpd and from Tomcat. That is generally a quite
>>> bad
>>> idea in terms of security, and also in terms of confusion, as you are
>>> experiencing here.
>>>
>>> To understand what is happening, you must look at it from the browser
>>> point
>>> of view.
>>>
>>> Step 1 :
>>>
>>> Your initial html document "index.html" is :
>>>
>>> <frameset rows="63,40,*" frameborder="0">
>>> <frame src="logo.html" name="logo" noresize scrolling="no"
>>> marginwidth="0" marginheight="
>>> 0">
>>> <frame src="View.jsp" name="toolbar" noresize scrolling="no"
>>> marginwidth="0" marginhei
>>> ght="0">
>>> <frame src="View2.jsp" name="ctrl">
>>> </frameset>
>>>
>>> and the browser loads it from the URL :
>>> http://<IP_address>/XYtest/jsp/Viewer/index.html
>>>
>>> Step 2 :
>>>
>>> In this document, the browser finds a reference to another document :
>>>
>>> <frame src="View.jsp" ..>
>>>
>>> The browser interprets that relative URL on the base of the origin of the
>>> current page, and then it asks the server for that document.
>>> So the browser requests the document (the inside frame) from the URL :
>>> http://<IP_address>/XYtest/jsp/Viewer/View.jsp
>>>
>>> Step 3 :
>>> The Apache httpd server receives the request for
>>>
>>> http://<IP_address>/XYtest/jsp/Viewer/View.jsp
>>>
>>> and it tries to match it with your proxy statement :
>>>
>>> ProxyPass /XYtest/*.jsp ajp://localhost:8009/XYtest
>>>
>>> It does not match (see below), so Apache httpd serves it itself, directly
>>> from disk.
>>> That is why you see the source : Tomcat never sees this request, and
>>> Apache
>>> has no idea that a ".jsp" file is anything else than text.
>>>
>>> Now why does it not match ?
>>> Because the ProxyPass directive does not understand wildcards or regexp.
>>> For that, you should us "ProxyPassMatch", for example like this :
>>>
>>> ProxyPassMatch "/XYtest/.*\.jsp$" ajp://localhost:8009/XYtest
>>>
>>> But it is still a bad idea.
>>> Why ?
>>>
>>> Suppose that in the directory /opt/test/XYtest, there is a sub-directory
>>> named "WEB-INF", and in that directory is a file "web.xml".
>>> This file is a configuration file for your Tomcat web application, and it
>>> may contain things like passwords for accessing a database for example.
>>> For that reason (security), Tomcat /never/ allows a user to request a
>>> document within the WEB-INF sub-directory of a web application.
>>>
>>> But with your setup, anyone can ask for the URL :
>>> http://<IP_address>/XYtest/WEB-INF/web.xml
>>>
>>> and Apache httpd will happily return that file (also as a text file).
>>> So, with you setup, you are bypassing an important security feature of
>>> Tomcat, because you are allowing Apache httpd to go "around it".
>>>
>>> There are different possibilities to fix your configuration.
>>> The first one would be to do this in Apache :
>>>
>>> ProxyPass /XYtest ajp://localhost:8009/XYtest
>>>
>>> and NOT define the directory /opt/test/XYtest in any way in Apache.
>>> That way, any request for a URL starting will /XYtest will be forwarded
>>> directly to Tomcat, and Tomcat will happily serve html pages (like
>>> index.html) as well as Apache.
>>> And it knows how to handle jsp pages too.
>>>
>>> Now, if all you want to do is serve html pages and jsp pages, you could
>>> also
>>> wonder if you need Apache httpd and mod_prox_ajp at all. You could set
>>> Tomcat to answer directly on port 80, get rid of Apache httpd, and
>>> simplify
>>> your configuration.
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
--
Best Regards / S pozdravem
Petr Hracek
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: JSP pages are not loaded. Only HTML source code
Posted by André Warnier <aw...@ice-sa.com>.
Quickly, because I have to get a train..
I think that this :
<Context docBase="/opt/test/servlet" allowLinking="true">
togethet with this :
<frame src="/XYtest/servlet/jsp/Viewer/View.jsp"
is wrong. You have a "servlet" too many there.
In other words,
"/XYtest/" already points to "/opt/test/servlet".
If you say "/XYtest/servlet/x", you are pointing to "/opt/test/servlet/servlet/x", no ?
Petr Hracek wrote:
> I have changed sources so that the actuall state is following:
>
> Apache things are in directory
> /opt/test/htdocs
> tomcat things are in directory
> /opt/test/servlet
>
> XYtest.xml is now:
> <?xml version='1.0' encoding='utf-8'?>
> <Context docBase="/opt/test/servlet" allowLinking="true">
> </Context>
>
> And jsp are stored in
> /opt/test/servlet/jsp/Viewer/View.jsp
>
> Updated HTML file stored in /opt/test/htdocs is:
> <frameset rows="63,40,*" frameborder="0">
> <frame src="logo.html" name="logo" noresize scrolling="no"
> marginwidth="0" marginheight="
> 0">
> <frame src="/XYtest/servlet/jsp/Viewer/View.jsp" name="toolbar"
> noresize scrolling="no"
> marginwidth="0" marginhei
> ght="0">
> <frame src="/XYtest/servlet/jsp/Viewer/View2.jsp" name="ctrl">
> </frameset>
>
> Apache has been updated accordingly:
> ProxyPass /XYtest/servlet ajp://localhost:8009/XYtest/servlet
> ProxyPassReverse /XYtest/servlet ajp://localhost:8009/XYtest/servlet
>
> Unfortunatelly it shows me: HTTP 404
>
> message /XYtest/servlet/jsp/Viewer/View.jsp
>
> description The requested resource
> (/XYtest/servlet/jsp/Viewer/View.jsp) is not available.
>
> What is wrong?
> Other servlets which did not used JSP are working properly.
>
> Thank you in advance
> Petr
>
>
> 2011/3/8 André Warnier <aw...@ice-sa.com>:
>> Petr Hracek wrote:
>>> Dear users,
>>>
>>> I would like to asked you on the some thing regarding JSP pages.
>>> On the Linux whereis installed apache 2.2.14 and tomcat 5.5.28
>> that's an old version of Tomcat. You should be using at least a 6.0.x
>> version by now.
>>
>> I would
>>> like to run
>>> JSP pages.
>>> JSP pages should be run over mod_proxy_ajp.
>>> URL is:
>>> http://<IP_address>/XYtest/jsp/Viewer/index.html
>>> ProxyPass /XYtest/*.jsp ajp://localhost:8009/XYtest
>>> ProxyPassReverse /XYtest/*.jsp ajp://localhost:8009/XYtest
>>>
>>> JSP page is called from HTML (index.html) and FRAME src "view.jsp"
>>> mentioned above.
>>> but instead of showing JSP page HTML source code is shown.
>>>
>>> Do you know what could be a reason?
>>> in the Catalina configuration directory
>>> (/etc/tomcat5/base/Catalina/localhost/XYtest.xml) is following context
>>> file
>>> test# cat /etc/tomcat/5/base/Catalina/locahost/XYtest.xml
>>> <?xml version='1.0' encoding='utf-8'?>
>>> <Context docBase="/opt/test/XYtest" allowLinking="true">
>>> </Context>
>>> test#
>>>
>>> structure in Linux is:
>>> /opt/test/XYtest/jsp/Viewer where are located files index.html and
>>> view.jsp which is part of FRAME
>>>
>> As a general observation : it looks like you are trying to serve the same
>> directory from Apache httpd and from Tomcat. That is generally a quite bad
>> idea in terms of security, and also in terms of confusion, as you are
>> experiencing here.
>>
>> To understand what is happening, you must look at it from the browser point
>> of view.
>>
>> Step 1 :
>>
>> Your initial html document "index.html" is :
>>
>> <frameset rows="63,40,*" frameborder="0">
>> <frame src="logo.html" name="logo" noresize scrolling="no"
>> marginwidth="0" marginheight="
>> 0">
>> <frame src="View.jsp" name="toolbar" noresize scrolling="no"
>> marginwidth="0" marginhei
>> ght="0">
>> <frame src="View2.jsp" name="ctrl">
>> </frameset>
>>
>> and the browser loads it from the URL :
>> http://<IP_address>/XYtest/jsp/Viewer/index.html
>>
>> Step 2 :
>>
>> In this document, the browser finds a reference to another document :
>>
>> <frame src="View.jsp" ..>
>>
>> The browser interprets that relative URL on the base of the origin of the
>> current page, and then it asks the server for that document.
>> So the browser requests the document (the inside frame) from the URL :
>> http://<IP_address>/XYtest/jsp/Viewer/View.jsp
>>
>> Step 3 :
>> The Apache httpd server receives the request for
>>
>> http://<IP_address>/XYtest/jsp/Viewer/View.jsp
>>
>> and it tries to match it with your proxy statement :
>>
>> ProxyPass /XYtest/*.jsp ajp://localhost:8009/XYtest
>>
>> It does not match (see below), so Apache httpd serves it itself, directly
>> from disk.
>> That is why you see the source : Tomcat never sees this request, and Apache
>> has no idea that a ".jsp" file is anything else than text.
>>
>> Now why does it not match ?
>> Because the ProxyPass directive does not understand wildcards or regexp.
>> For that, you should us "ProxyPassMatch", for example like this :
>>
>> ProxyPassMatch "/XYtest/.*\.jsp$" ajp://localhost:8009/XYtest
>>
>> But it is still a bad idea.
>> Why ?
>>
>> Suppose that in the directory /opt/test/XYtest, there is a sub-directory
>> named "WEB-INF", and in that directory is a file "web.xml".
>> This file is a configuration file for your Tomcat web application, and it
>> may contain things like passwords for accessing a database for example.
>> For that reason (security), Tomcat /never/ allows a user to request a
>> document within the WEB-INF sub-directory of a web application.
>>
>> But with your setup, anyone can ask for the URL :
>> http://<IP_address>/XYtest/WEB-INF/web.xml
>>
>> and Apache httpd will happily return that file (also as a text file).
>> So, with you setup, you are bypassing an important security feature of
>> Tomcat, because you are allowing Apache httpd to go "around it".
>>
>> There are different possibilities to fix your configuration.
>> The first one would be to do this in Apache :
>>
>> ProxyPass /XYtest ajp://localhost:8009/XYtest
>>
>> and NOT define the directory /opt/test/XYtest in any way in Apache.
>> That way, any request for a URL starting will /XYtest will be forwarded
>> directly to Tomcat, and Tomcat will happily serve html pages (like
>> index.html) as well as Apache.
>> And it knows how to handle jsp pages too.
>>
>> Now, if all you want to do is serve html pages and jsp pages, you could also
>> wonder if you need Apache httpd and mod_prox_ajp at all. You could set
>> Tomcat to answer directly on port 80, get rid of Apache httpd, and simplify
>> your configuration.
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: JSP pages are not loaded. Only HTML source code
Posted by Petr Hracek <ph...@gmail.com>.
I have changed sources so that the actuall state is following:
Apache things are in directory
/opt/test/htdocs
tomcat things are in directory
/opt/test/servlet
XYtest.xml is now:
<?xml version='1.0' encoding='utf-8'?>
<Context docBase="/opt/test/servlet" allowLinking="true">
</Context>
And jsp are stored in
/opt/test/servlet/jsp/Viewer/View.jsp
Updated HTML file stored in /opt/test/htdocs is:
<frameset rows="63,40,*" frameborder="0">
<frame src="logo.html" name="logo" noresize scrolling="no"
marginwidth="0" marginheight="
0">
<frame src="/XYtest/servlet/jsp/Viewer/View.jsp" name="toolbar"
noresize scrolling="no"
marginwidth="0" marginhei
ght="0">
<frame src="/XYtest/servlet/jsp/Viewer/View2.jsp" name="ctrl">
</frameset>
Apache has been updated accordingly:
ProxyPass /XYtest/servlet ajp://localhost:8009/XYtest/servlet
ProxyPassReverse /XYtest/servlet ajp://localhost:8009/XYtest/servlet
Unfortunatelly it shows me: HTTP 404
message /XYtest/servlet/jsp/Viewer/View.jsp
description The requested resource
(/XYtest/servlet/jsp/Viewer/View.jsp) is not available.
What is wrong?
Other servlets which did not used JSP are working properly.
Thank you in advance
Petr
2011/3/8 André Warnier <aw...@ice-sa.com>:
> Petr Hracek wrote:
>>
>> Dear users,
>>
>> I would like to asked you on the some thing regarding JSP pages.
>> On the Linux whereis installed apache 2.2.14 and tomcat 5.5.28
>
> that's an old version of Tomcat. You should be using at least a 6.0.x
> version by now.
>
> I would
>>
>> like to run
>> JSP pages.
>> JSP pages should be run over mod_proxy_ajp.
>> URL is:
>> http://<IP_address>/XYtest/jsp/Viewer/index.html
>> ProxyPass /XYtest/*.jsp ajp://localhost:8009/XYtest
>> ProxyPassReverse /XYtest/*.jsp ajp://localhost:8009/XYtest
>>
>> JSP page is called from HTML (index.html) and FRAME src "view.jsp"
>> mentioned above.
>> but instead of showing JSP page HTML source code is shown.
>>
>> Do you know what could be a reason?
>> in the Catalina configuration directory
>> (/etc/tomcat5/base/Catalina/localhost/XYtest.xml) is following context
>> file
>> test# cat /etc/tomcat/5/base/Catalina/locahost/XYtest.xml
>> <?xml version='1.0' encoding='utf-8'?>
>> <Context docBase="/opt/test/XYtest" allowLinking="true">
>> </Context>
>> test#
>>
>> structure in Linux is:
>> /opt/test/XYtest/jsp/Viewer where are located files index.html and
>> view.jsp which is part of FRAME
>>
>
> As a general observation : it looks like you are trying to serve the same
> directory from Apache httpd and from Tomcat. That is generally a quite bad
> idea in terms of security, and also in terms of confusion, as you are
> experiencing here.
>
> To understand what is happening, you must look at it from the browser point
> of view.
>
> Step 1 :
>
> Your initial html document "index.html" is :
>
> <frameset rows="63,40,*" frameborder="0">
> <frame src="logo.html" name="logo" noresize scrolling="no"
> marginwidth="0" marginheight="
> 0">
> <frame src="View.jsp" name="toolbar" noresize scrolling="no"
> marginwidth="0" marginhei
> ght="0">
> <frame src="View2.jsp" name="ctrl">
> </frameset>
>
> and the browser loads it from the URL :
> http://<IP_address>/XYtest/jsp/Viewer/index.html
>
> Step 2 :
>
> In this document, the browser finds a reference to another document :
>
> <frame src="View.jsp" ..>
>
> The browser interprets that relative URL on the base of the origin of the
> current page, and then it asks the server for that document.
> So the browser requests the document (the inside frame) from the URL :
> http://<IP_address>/XYtest/jsp/Viewer/View.jsp
>
> Step 3 :
> The Apache httpd server receives the request for
>
> http://<IP_address>/XYtest/jsp/Viewer/View.jsp
>
> and it tries to match it with your proxy statement :
>
> ProxyPass /XYtest/*.jsp ajp://localhost:8009/XYtest
>
> It does not match (see below), so Apache httpd serves it itself, directly
> from disk.
> That is why you see the source : Tomcat never sees this request, and Apache
> has no idea that a ".jsp" file is anything else than text.
>
> Now why does it not match ?
> Because the ProxyPass directive does not understand wildcards or regexp.
> For that, you should us "ProxyPassMatch", for example like this :
>
> ProxyPassMatch "/XYtest/.*\.jsp$" ajp://localhost:8009/XYtest
>
> But it is still a bad idea.
> Why ?
>
> Suppose that in the directory /opt/test/XYtest, there is a sub-directory
> named "WEB-INF", and in that directory is a file "web.xml".
> This file is a configuration file for your Tomcat web application, and it
> may contain things like passwords for accessing a database for example.
> For that reason (security), Tomcat /never/ allows a user to request a
> document within the WEB-INF sub-directory of a web application.
>
> But with your setup, anyone can ask for the URL :
> http://<IP_address>/XYtest/WEB-INF/web.xml
>
> and Apache httpd will happily return that file (also as a text file).
> So, with you setup, you are bypassing an important security feature of
> Tomcat, because you are allowing Apache httpd to go "around it".
>
> There are different possibilities to fix your configuration.
> The first one would be to do this in Apache :
>
> ProxyPass /XYtest ajp://localhost:8009/XYtest
>
> and NOT define the directory /opt/test/XYtest in any way in Apache.
> That way, any request for a URL starting will /XYtest will be forwarded
> directly to Tomcat, and Tomcat will happily serve html pages (like
> index.html) as well as Apache.
> And it knows how to handle jsp pages too.
>
> Now, if all you want to do is serve html pages and jsp pages, you could also
> wonder if you need Apache httpd and mod_prox_ajp at all. You could set
> Tomcat to answer directly on port 80, get rid of Apache httpd, and simplify
> your configuration.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
--
Best Regards / S pozdravem
Petr Hracek
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: JSP pages are not loaded. Only HTML source code
Posted by André Warnier <aw...@ice-sa.com>.
Petr Hracek wrote:
> Dear users,
>
> I would like to asked you on the some thing regarding JSP pages.
> On the Linux whereis installed apache 2.2.14 and tomcat 5.5.28
that's an old version of Tomcat. You should be using at least a 6.0.x version by now.
I would
> like to run
> JSP pages.
> JSP pages should be run over mod_proxy_ajp.
> URL is:
> http://<IP_address>/XYtest/jsp/Viewer/index.html
> ProxyPass /XYtest/*.jsp ajp://localhost:8009/XYtest
> ProxyPassReverse /XYtest/*.jsp ajp://localhost:8009/XYtest
>
> JSP page is called from HTML (index.html) and FRAME src "view.jsp"
> mentioned above.
> but instead of showing JSP page HTML source code is shown.
>
> Do you know what could be a reason?
> in the Catalina configuration directory
> (/etc/tomcat5/base/Catalina/localhost/XYtest.xml) is following context
> file
> test# cat /etc/tomcat/5/base/Catalina/locahost/XYtest.xml
> <?xml version='1.0' encoding='utf-8'?>
> <Context docBase="/opt/test/XYtest" allowLinking="true">
> </Context>
> test#
>
> structure in Linux is:
> /opt/test/XYtest/jsp/Viewer where are located files index.html and
> view.jsp which is part of FRAME
>
As a general observation : it looks like you are trying to serve the same directory from
Apache httpd and from Tomcat. That is generally a quite bad idea in terms of security,
and also in terms of confusion, as you are experiencing here.
To understand what is happening, you must look at it from the browser point of view.
Step 1 :
Your initial html document "index.html" is :
<frameset rows="63,40,*" frameborder="0">
<frame src="logo.html" name="logo" noresize scrolling="no"
marginwidth="0" marginheight="
0">
<frame src="View.jsp" name="toolbar" noresize scrolling="no"
marginwidth="0" marginhei
ght="0">
<frame src="View2.jsp" name="ctrl">
</frameset>
and the browser loads it from the URL :
http://<IP_address>/XYtest/jsp/Viewer/index.html
Step 2 :
In this document, the browser finds a reference to another document :
<frame src="View.jsp" ..>
The browser interprets that relative URL on the base of the origin of the current page,
and then it asks the server for that document.
So the browser requests the document (the inside frame) from the URL :
http://<IP_address>/XYtest/jsp/Viewer/View.jsp
Step 3 :
The Apache httpd server receives the request for
http://<IP_address>/XYtest/jsp/Viewer/View.jsp
and it tries to match it with your proxy statement :
ProxyPass /XYtest/*.jsp ajp://localhost:8009/XYtest
It does not match (see below), so Apache httpd serves it itself, directly from disk.
That is why you see the source : Tomcat never sees this request, and Apache has no idea
that a ".jsp" file is anything else than text.
Now why does it not match ?
Because the ProxyPass directive does not understand wildcards or regexp.
For that, you should us "ProxyPassMatch", for example like this :
ProxyPassMatch "/XYtest/.*\.jsp$" ajp://localhost:8009/XYtest
But it is still a bad idea.
Why ?
Suppose that in the directory /opt/test/XYtest, there is a sub-directory named "WEB-INF",
and in that directory is a file "web.xml".
This file is a configuration file for your Tomcat web application, and it may contain
things like passwords for accessing a database for example.
For that reason (security), Tomcat /never/ allows a user to request a document within the
WEB-INF sub-directory of a web application.
But with your setup, anyone can ask for the URL :
http://<IP_address>/XYtest/WEB-INF/web.xml
and Apache httpd will happily return that file (also as a text file).
So, with you setup, you are bypassing an important security feature of Tomcat, because you
are allowing Apache httpd to go "around it".
There are different possibilities to fix your configuration.
The first one would be to do this in Apache :
ProxyPass /XYtest ajp://localhost:8009/XYtest
and NOT define the directory /opt/test/XYtest in any way in Apache.
That way, any request for a URL starting will /XYtest will be forwarded directly to
Tomcat, and Tomcat will happily serve html pages (like index.html) as well as Apache.
And it knows how to handle jsp pages too.
Now, if all you want to do is serve html pages and jsp pages, you could also wonder if you
need Apache httpd and mod_prox_ajp at all. You could set Tomcat to answer directly on port
80, get rid of Apache httpd, and simplify your configuration.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org