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

JSP views rendering 0 bytes and HTTP 200

 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[DISCLAIMER: This is a duplicate for a question I posted in the official forums but haven't received any replies yet]

I've got a weird problem I haven't been able to figure out.

Using the following viewResolver configuration renders a pretty Velocity template:

For example, new ModelAndView("foo") renders the template from /WEB-INF/velocity/foo.vm.

However, when I tried to create a similar configuration for rendering JSP's (and commented out the Velocity stuff), I'm getting a HTTP 200 with no content at all.

Trying to access the URL http://localhost:8080/myapp/foo.html (I've mapped the DispatcherServlet to "*.html") results in the following log output:

What wonders me is that the log clearly claims the request was forwarded to "/WEB-INF/jsp/list.jsp" but the JSP is never rendered. Instead, as I mentioned already, I get 0 bytes of content and a HTTP 200 response code.

Here's the web.xml stuff that maps the request to the controller:


Any help is obviously appreciated. Especially if it makes me slap my forehead ;-)
[ October 10, 2005: Message edited by: Lasse Koskela ]
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The first thing I'd try is to remove the jsp from the WEB-INF directory, just to be sure. Ben will disagree, but I've seen some weird behaviour trying this that has con vinced me not to do it.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the tip, although I have tried putting my JSP's both in "/*.jsp" as well as "/jsp/*.jsp" and "/WEB-INF/jsp/*.jsp" -- all with the same result.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
More stuff which is really just sanity checks:

* add some logging to the JSP to see if it is executing at all. While I can't believe it would parse the file then omit the output without an error, I can imagine it.
* It may be stale, try deleting all of your compiled JSPs.

I'm trying to think of something in Spring which may create this effect, but my experience doesn't go deep enough. If you use Log4J and turn it onto DEBUG you'll get more information than you'll ever need.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by David O'Meara:
* add some logging to the JSP to see if it is executing at all. While I can't believe it would parse the file then omit the output without an error, I can imagine it.
* It may be stale, try deleting all of your compiled JSPs.


I did try adding the classic System.out.println and it doesn't say anything. In other words, the JSP doesn't seem to get invoked at all.
I didn't try to delete the working directories, although I think the build script might be creating a clean copy of the Tomcat "/work" directory (I'm using Cargo's Ant tasks).

Originally posted by David O'Meara:
I'm trying to think of something in Spring which may create this effect, but my experience doesn't go deep enough. If you use Log4J and turn it onto DEBUG you'll get more information than you'll ever need.


The output I posted above is actually from the DEBUG level. I just ripped away the "excess" information to make it fit even somehow on the screen

Thanks again. I'll report back whether deleting the compiled JSP's will help.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should be able to safely delete the contents of the 'work' directory. (not the directory itself, just the contents.) From memory System.out won't work in Tomcat, it just gets lost, but I may be wrong.

My contact with Spring was fairly light, allowing us to abstract Hibernate and manage the usual transaction stuff, hence I'm treating this as a JSP problem
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, while I'm racking my brain for strange behaviour:

Check the source returned and search for any content from the JSP, even if is not where you expected it to be. I've seen threading problems before where output was being returned but treated as 'white space' by the browser since its response was not synchronised with the other parts. Strange but true.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by David O'Meara:
From memory System.out won't work in Tomcat, it just gets lost, but I may be wrong.

It works at least from Servlets (in Tomcat 5.5). Hmm. Maybe I should try putting System.exit() into the JSP and see what happens

Originally posted by David O'Meara:
Check the source returned and search for any content from the JSP, even if is not where you expected it to be. I've seen threading problems before where output was being returned but treated as 'white space' by the browser since its response was not synchronised with the other parts. Strange but true.


Ah. I actually tried wget which reported zero bytes downloaded.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry. I forgot to post here that I eventually solved the problem by downgrading from Tomcat 5.5.9 to 5.0.28. Don't know what made the difference and didn't even try to find out.

On 5.0.28 everything works smoothly -- the same code, the same configuration, everything.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic