You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2011/09/26 20:28:09 UTC

DO NOT REPLY [Bug 51894] New: Dynamic includes (with jsp:include or in Java code) of static content fails with Spring + Tomcat

https://issues.apache.org/bugzilla/show_bug.cgi?id=51894

             Bug #: 51894
           Summary: Dynamic includes (with jsp:include or in Java code) of
                    static content fails with Spring + Tomcat
           Product: Tomcat 7
           Version: 7.0.21
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: jwu@digitalmeasures.com
    Classification: Unclassified


The contents of an including JSP are delivered, and an exception thrown, when
attempting to include static contents with <jsp:include/>. The error also
occurs when including dynamically with Java code; in this case no content is
delivered. Attached is a bare-bones spring web-app that exhibits this behavior
when the war file is run in Tomcat.


{servlet}/helloworld/dynamic returns (as expected):
<html>
<body>
<p>Hello World!</p>
</body>
</html>


{servlet}/helloworld/static should return the same as above but instead
returns:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:include page="include/helloWorld.html"/>

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 51894] Dynamic includes (with jsp:include or in Java code) of static content fails with Spring + Tomcat

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51894

--- Comment #5 from Konstantin Kolinko <kn...@gmail.com> 2011-09-27 00:30:44 UTC ---
Please provide a WAR file (without Spring libraries - those can be downloaded),
so that it can be tested.

Thus I cannot test the app itself. Testing the views and reviewing
configuration instead.

1. Accessing the views directly does work. Forwarding to your views works as
well (that is what DispatcherServlet does when displaying a view).
So it is a problem with your configuration.

2. You mapped DispatcherServlet to <url-pattern>/</url-pattern>. It is wrong,
because it conflicts with mapping of DefaultServlet (in conf/web.xml).


In short: DefaultServlet is the servlet that is used to serve static files. In
your configuration the nested request to helloWorld.html is served not by
DefaultServlet but by DispatcherServlet.

Whatever happens in this case is beyond my scope.
IIRC in such cases DispatcherServlet responds with HTTP response code 400
(wrong request), because it cannot map request to proper controller.

Closing as INVALID: you should fix your mapping for static resources.
For example, configure org.apache.catalina.servlets.DefaultServlet explicitly
and map it to *.html URLs.  Or change the mapping for DispatcherServlet so that
there would not be a conflict.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 51894] Dynamic includes (with jsp:include or in Java code) of static content fails with Spring + Tomcat

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51894

--- Comment #1 from Jacob Wu <jw...@digitalmeasures.com> 2011-09-26 18:32:13 UTC ---
Created attachment 27598
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=27598
Demonstration

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 51894] Dynamic includes (with jsp:include or in Java code) of static content fails with Spring + Tomcat

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51894

--- Comment #3 from Jacob Wu <jw...@digitalmeasures.com> 2011-09-26 19:08:08 UTC ---
"<mvc:default-servlet-handler/>" configures spring to forward requests for
static content along to the servlet container's default servlet.

http://static.springsource.org/spring/docs/current/spring-framework-reference/html/mvc.html#mvc-default-servlet-handler

(In reply to comment #2)
> I'm not a Spring user: does the "<mvc:default-servlet-handler/>" in
> demo-servlet.xml configure Spring's front controller to act like the "default"
> servlet and therefore serve static content? Otherwise, it looks like you have
> mapped / to Spring and then only handled *.jsp URLs.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 51894] Dynamic includes (with jsp:include or in Java code) of static content fails with Spring + Tomcat

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51894

--- Comment #6 from Mark Thomas <ma...@apache.org> 2011-09-27 10:09:48 UTC ---
There were issues in previous versions when applications tried to override the
default servlet but those have been fixed. Just to be sure, I double checked
using

<servlet-mapping>
  <servlet-name>HelloWorld</servlet-name>
  <url-pattern>/</url-pattern>
</servlet-mapping>

and

@WebServlet("/")

and both worked as expected.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 51894] Dynamic includes (with jsp:include or in Java code) of static content fails with Spring + Tomcat

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51894

--- Comment #8 from Mark Thomas <ma...@apache.org> 2011-09-27 14:02:09 UTC ---
trunk

The bug I was referring to was fixed in 7.0.15 and there are no changes I can
recall or see in the change log that should modify the behaviour in this area
between 7.0.21 and trunk.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 51894] Dynamic includes (with jsp:include or in Java code) of static content fails with Spring + Tomcat

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51894

--- Comment #9 from Jacob Wu <jw...@digitalmeasures.com> 2011-09-27 14:03:34 UTC ---
We are still experiencing it in 7.0.21

(In reply to comment #8)
> trunk
> 
> The bug I was referring to was fixed in 7.0.15 and there are no changes I can
> recall or see in the change log that should modify the behaviour in this area
> between 7.0.21 and trunk.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 51894] Dynamic includes (with jsp:include or in Java code) of static content fails with Spring + Tomcat

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51894

--- Comment #2 from Christopher Schultz <ch...@christopherschultz.net> 2011-09-26 19:01:24 UTC ---
I'm not a Spring user: does the "<mvc:default-servlet-handler/>" in
demo-servlet.xml configure Spring's front controller to act like the "default"
servlet and therefore serve static content? Otherwise, it looks like you have
mapped / to Spring and then only handled *.jsp URLs.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 51894] Dynamic includes (with jsp:include or in Java code) of static content fails with Spring + Tomcat

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51894

Konstantin Kolinko <kn...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 51894] Dynamic includes (with jsp:include or in Java code) of static content fails with Spring + Tomcat

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51894

--- Comment #10 from Konstantin Kolinko <kn...@gmail.com> 2011-09-27 14:18:44 UTC ---
(In reply to comment #6)
> There were issues in previous versions when applications tried to override the
> default servlet but those have been fixed. Just to be sure, I double checked
> using
> 
> <servlet-mapping>
>   <servlet-name>HelloWorld</servlet-name>
>   <url-pattern>/</url-pattern>
> </servlet-mapping>
> 
> and
> 
> @WebServlet("/")
> 
> and both worked as expected.

If this mapping were not working, their views were not working at all.

(Because they are in WEB-INF and thus are not accessible without that
DispatcherServlet that performs forward to them).

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 51894] Dynamic includes (with jsp:include or in Java code) of static content fails with Spring + Tomcat

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51894

--- Comment #7 from Jacob Wu <jw...@digitalmeasures.com> 2011-09-27 13:57:01 UTC ---
With which version of Tomcat did this work for you?

(In reply to comment #6)
> There were issues in previous versions when applications tried to override the
> default servlet but those have been fixed. Just to be sure, I double checked
> using
> 
> <servlet-mapping>
>   <servlet-name>HelloWorld</servlet-name>
>   <url-pattern>/</url-pattern>
> </servlet-mapping>
> 
> and
> 
> @WebServlet("/")
> 
> and both worked as expected.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 51894] Dynamic includes (with jsp:include or in Java code) of static content fails with Spring + Tomcat

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51894

--- Comment #4 from Jacob Wu <jw...@digitalmeasures.com> 2011-09-26 19:14:26 UTC ---
I should also mention that we tried dynamically including static content in
Jetty and it worked as we had expected.  The attached sample also works in
Jetty but not on tomcat.

Tomcat as far back as 6.0.29 has been tested; all failed to work as we
expected.

(In reply to comment #0)

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org