You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Scott Dunbar <sc...@xigole.com> on 2007/05/07 22:56:33 UTC

jsp:include no longer working in 5.5.23

I've been using the same code for years since the Tomcat 3.x days and an 
upgrade to 5.5.23 has now broken my site.

If I do a:

<jsp:include page="/some/path/to/some.html" />

I get:

The requested resource (/some/path/to/some.html) is not available.  It 
is available and this particular file hasn't been modified for a very 
long time.  If I change it to:

<jsp:include page="../some/path/to/some.html" />

which is where it is physically, I get

Stacktrace:
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:467)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:389)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

*root cause*

java.lang.NullPointerException
	org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:965)
	org.apache.jsp.index_jsp._jspService(index_jsp.java:42)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


Any thoughts?




Re: jsp:include no longer working in 5.5.23

Posted by David Smith <dn...@cornell.edu>.
The organization of webapps isn't tree oriented on disk.  It's a flat 
list of webapps on disk with the "default" webapp being named the 
special name ROOT (defined by the servlet spec).  If you need webapps 
organized deeper than the top level (ie /myWeb/path/app), then you use 
the pound symbol as a path separator in the webapp's name (ie 
myWeb#path#app).  Unfortunately that trick seems to only work in a very 
limited set of circumstances.  You can search the list for where this 
works or doesn't work.

Don't overlap the webapps directory and the apache httpd virtual 
directory.  It's cleaner to keep the two separated.  Instead organize 
your content so static resources served by apache httpd are in a apache 
httpd directory.  It seems to me what you are really after is the way 
php works and you can't get that with tomcat.

--David

Scott Dunbar wrote:
> Thanks for the input.  However, I guess I'm still missing something.
>
> I want a directory to be the root directory of a virtual host.  That 
> directory is itself a webapp and may have other directories within it 
> that are webapps (with explicit Context elements).  To this point I 
> have never had to have a different directory from my default stuff.  
> In effect this change means that there is no such thing as a default 
> webapp directory - it must be explicitly enumerated.  There is a 
> Tomcat proprietary convention of naming a default one ROOT but that 
> will complicate my move to any other app server.  It also complicates 
> an Apache httpd and Tomcat environment.  Previously I was able to put 
> the Apache httpd VirtualHost DocumentRoot and the Tomcat Host appBase 
> at the same place and have httpd serve static content while Tomcat 
> served dynamic content.  Now I have to change my directory structure 
> because there are really two different places to get root level 
> things.  For example, doing a jsp:include of /something.jsp comes from 
> a different directory than including CSS from /styles.css.  This just 
> seems more complicated to me.  You really can not overlay 
> VirtualHost's and Host's anymore.
>
> Is what I'm trying to do wrong?  My frustration stems from the fact 
> that I always been able to have a directory that is the root and, 
> optionally, separate directories under the root that are webapps with 
> their own Context.  What you're saying is that I can't do that - I 
> need an explicit directory for my default webapp that is different 
> from the root of the virtual host (though it can be a child of it).  
> That complicates the directory structure and, since the Tomcat 3.x 
> days through at least 5.5.15 is not the way it worked.
>
> I guess what I'm looking for is a true default Context but it seems 
> that that no longer exists - it must be explicit.  This could explain 
> some other problems I'm having with JRoller not being able to be the 
> top of a virtual host anymore with 5.5.23 (and, with some 
> experimentation, 5.5.20 also).
>
> I'll continue to experiment - thanks for your help.
>
>
>
> Mark Thomas wrote:
>> Scott Dunbar wrote:
>>  
>>> Thanks, I checked that and my I don't set a docBase in my context:
>>>
>>> <Host name="domainname.tld" appBase="/home/scott/sites/domainname.tld"
>>>              unpackWARs="true" autoDeploy="true"
>>>              xmlValidation="false" xmlNamespaceAware="false">
>>>
>>>            <Context path="" docBase="" />
>>>     
>>
>> And there is the problem. If it isn't absolute, docBase is relative to
>> appBase so you do have appBase == docBase
>>
>> To fix this:
>> - remove the Context element from your server.xml
>> - assuming you have only one webapp deployed, move the contents of
>> /home/scott/sites/domainname.tld to 
>> /home/scott/sites/domainname.tld/ROOT
>> - if you have multiple webapps deployed, just move the files that are
>> part of the ROOT webapp
>>
>> Mark
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>   
>
>


-- 
David Smith
Network Operations Supervisor
Department of Entomology
Cornell University
2132 Comstock Hall
Ithaca, NY 14853
Phone: (607) 255-9571
Fax: (607) 255-0940


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: jsp:include no longer working in 5.5.23

Posted by Scott Dunbar <sc...@xigole.com>.
No need to apologize - learning requires making mistakes and I 
appreciate the responses that you and David Smith gave in pointing me in 
the right direction.  I've got some work to do but I now understand much 
better that I was getting away with something for quite some time and 
shouldn't have been.

Again, thanks for the help.



Mark Thomas wrote:
> Scott Dunbar wrote:
>   
>> Is what I'm trying to do wrong?
>>     
> Sorry, but yes.
>   

Re: jsp:include no longer working in 5.5.23

Posted by Mark Thomas <ma...@apache.org>.
Scott Dunbar wrote:
> I want a directory to be the root directory of a virtual host.  That
> directory is itself a webapp and may have other directories within it
> that are webapps (with explicit Context elements). 
You simply can't do this. Tomcat was never intended to work this way.
As I said before, that it used to work this way was a side-effect of a
since fixed bug.

> To this point I have
> never had to have a different directory from my default stuff.  In
> effect this change means that there is no such thing as a default webapp
> directory - it must be explicitly enumerated.
Yes there is. It is just called ROOT rather than being the appBase for
the host.

>  There is a Tomcat
> proprietary convention of naming a default one ROOT but that will
> complicate my move to any other app server.
It shouldn't. Build your war. Do whatever the app requires to define
it as the ROOT webapp and deploy it.

>  It also complicates an
> Apache httpd and Tomcat environment.  Previously I was able to put the
> Apache httpd VirtualHost DocumentRoot and the Tomcat Host appBase at the
> same place and have httpd serve static content while Tomcat served
> dynamic content.
This is extremely dangerous from a security point of view. You are
very likely to see source code disclosure issues with your JSPs if you
run your site like this.

>  Now I have to change my directory structure because
> there are really two different places to get root level things.  For
> example, doing a jsp:include of /something.jsp comes from a different
> directory than including CSS from /styles.css.  This just seems more
> complicated to me.  You really can not overlay VirtualHost's and Host's
> anymore.
Yes, I am afraid you do need to change your directory structure. Not
least because of the security issues.

> Is what I'm trying to do wrong?
Sorry, but yes.

>  My frustration stems from the fact that
> I always been able to have a directory that is the root and, optionally,
> separate directories under the root that are webapps with their own
> Context.  What you're saying is that I can't do that - I need an
> explicit directory for my default webapp that is different from the root
> of the virtual host (though it can be a child of it).
The httpd virtual host root should be separate from Tomcat's appBase
which in turn should not be the same as any of the docBase values for
Contexts deployed in that host.

>  That complicates
> the directory structure and, since the Tomcat 3.x days through at least
> 5.5.15 is not the way it worked.
At the risk of getting boring with the repetition - it was never
intended to work this way.

> I guess what I'm looking for is a true default Context but it seems that
> that no longer exists - it must be explicit.  This could explain some
> other problems I'm having with JRoller not being able to be the top of a
> virtual host anymore with 5.5.23 (and, with some experimentation, 5.5.20
> also).
What you are looking for doesn't exist. You might be able to hack it
into working but you would need to be extremely careful.

Mark

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: jsp:include no longer working in 5.5.23

Posted by Scott Dunbar <sc...@xigole.com>.
Thanks for the input.  However, I guess I'm still missing something.

I want a directory to be the root directory of a virtual host.  That 
directory is itself a webapp and may have other directories within it 
that are webapps (with explicit Context elements).  To this point I have 
never had to have a different directory from my default stuff.  In 
effect this change means that there is no such thing as a default webapp 
directory - it must be explicitly enumerated.  There is a Tomcat 
proprietary convention of naming a default one ROOT but that will 
complicate my move to any other app server.  It also complicates an 
Apache httpd and Tomcat environment.  Previously I was able to put the 
Apache httpd VirtualHost DocumentRoot and the Tomcat Host appBase at the 
same place and have httpd serve static content while Tomcat served 
dynamic content.  Now I have to change my directory structure because 
there are really two different places to get root level things.  For 
example, doing a jsp:include of /something.jsp comes from a different 
directory than including CSS from /styles.css.  This just seems more 
complicated to me.  You really can not overlay VirtualHost's and Host's 
anymore.

Is what I'm trying to do wrong?  My frustration stems from the fact that 
I always been able to have a directory that is the root and, optionally, 
separate directories under the root that are webapps with their own 
Context.  What you're saying is that I can't do that - I need an 
explicit directory for my default webapp that is different from the root 
of the virtual host (though it can be a child of it).  That complicates 
the directory structure and, since the Tomcat 3.x days through at least 
5.5.15 is not the way it worked.

I guess what I'm looking for is a true default Context but it seems that 
that no longer exists - it must be explicit.  This could explain some 
other problems I'm having with JRoller not being able to be the top of a 
virtual host anymore with 5.5.23 (and, with some experimentation, 5.5.20 
also).

I'll continue to experiment - thanks for your help.



Mark Thomas wrote:
> Scott Dunbar wrote:
>   
>> Thanks, I checked that and my I don't set a docBase in my context:
>>
>> <Host name="domainname.tld" appBase="/home/scott/sites/domainname.tld"
>>              unpackWARs="true" autoDeploy="true"
>>              xmlValidation="false" xmlNamespaceAware="false">
>>
>>            <Context path="" docBase="" />
>>     
>
> And there is the problem. If it isn't absolute, docBase is relative to
> appBase so you do have appBase == docBase
>
> To fix this:
> - remove the Context element from your server.xml
> - assuming you have only one webapp deployed, move the contents of
> /home/scott/sites/domainname.tld to /home/scott/sites/domainname.tld/ROOT
> - if you have multiple webapps deployed, just move the files that are
> part of the ROOT webapp
>
> Mark
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>   


Re: jsp:include no longer working in 5.5.23

Posted by Mark Thomas <ma...@apache.org>.
Scott Dunbar wrote:
> Thanks, I checked that and my I don't set a docBase in my context:
> 
> <Host name="domainname.tld" appBase="/home/scott/sites/domainname.tld"
>              unpackWARs="true" autoDeploy="true"
>              xmlValidation="false" xmlNamespaceAware="false">
> 
>            <Context path="" docBase="" />

And there is the problem. If it isn't absolute, docBase is relative to
appBase so you do have appBase == docBase

To fix this:
- remove the Context element from your server.xml
- assuming you have only one webapp deployed, move the contents of
/home/scott/sites/domainname.tld to /home/scott/sites/domainname.tld/ROOT
- if you have multiple webapps deployed, just move the files that are
part of the ROOT webapp

Mark


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: jsp:include no longer working in 5.5.23

Posted by Scott Dunbar <sc...@xigole.com>.
Thanks, I checked that and my I don't set a docBase in my context:

<Host name="domainname.tld" appBase="/home/scott/sites/domainname.tld"
              unpackWARs="true" autoDeploy="true"
              xmlValidation="false" xmlNamespaceAware="false">

            <Context path="" docBase="" />
...

This exact same server.xml works fine under 5.5.15 which I've been 
running for about 16 months.  I'll keep digging but after being bit by a 
bug in 5.5.16 I need to be much more careful with upgrading to new 
Tomcat versions.  Thanks for the suggestion.




Mark Thomas wrote:
> Scott Dunbar wrote:
>   
>> I've been using the same code for years since the Tomcat 3.x days and an
>> upgrade to 5.5.23 has now broken my site.
>>     
>
> Check your config for appBase in a host element being set to the same
> directory as the docBase for a context. Most likely this will be in a
> ROOT context for the host.
>
> appBase = docBase should never have worked but did as a side effect of
> a a bug that was fixed a few releases ago.
>
>
> HTH,
>
> Mark
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>   


Re: jsp:include no longer working in 5.5.23

Posted by Mark Thomas <ma...@apache.org>.
Scott Dunbar wrote:
> I've been using the same code for years since the Tomcat 3.x days and an
> upgrade to 5.5.23 has now broken my site.

Check your config for appBase in a host element being set to the same
directory as the docBase for a context. Most likely this will be in a
ROOT context for the host.

appBase = docBase should never have worked but did as a side effect of
a a bug that was fixed a few releases ago.


HTH,

Mark

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: jsp:include no longer working in 5.5.23

Posted by Rashmi Rubdi <ra...@gmail.com>.
On 5/7/07, Scott Dunbar <sc...@xigole.com> wrote:
> I've been using the same code for years since the Tomcat 3.x days and an
> upgrade to 5.5.23 has now broken my site.

I would safely assume there have been significant changes between 3.x
and 5.5.23, if I were you I would start fresh, also the instructions
for 5.5.23 are different compared to older versions.

Tomcat 3.x follows JSP 1.1 syntax

Tomcat 5.5.x follows JSP 2.0 syntax

> If I do a:
>
> <jsp:include page="/some/path/to/some.html" />
>

In the above page URL, what is some? Is it a folder under the root
context or is /some/ the context itself?

Knowing the absolute path of some.html would help in knowing whether
it's under a root context or not.

> I get:
>
> The requested resource (/some/path/to/some.html) is not available.  It
> is available and this particular file hasn't been modified for a very
> long time.  If I change it to:
>
> <jsp:include page="../some/path/to/some.html" />
>
> which is where it is physically, I get

Most likely the path is incorrect, knowing the absolute path helps, in
diagnosing the problem

>
> Stacktrace:
>         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:467)
>         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:389)
>         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
>         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
>         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>
> *root cause*
>
> java.lang.NullPointerException
>         org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:965)
>         org.apache.jsp.index_jsp._jspService(index_jsp.java:42)
>         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
>         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
>         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
>         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
>         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>
>
> Any thoughts?
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org