简体   繁体   中英

JSP renders weird HTML

I'm getting a very strange behaviour in one of my JSP pages. It looks like it doesn't render the complete HTML. It looks like this:

<html>
   ...
   <table>
   ...
   </table>
   <div id=

So the last line is exactly what you get when the page is rendered. Furthermore, when you do a view source you get exactly the same. This page doesn't have any fancy logic ... there are no javascript erros, no missing closing tags, etc ...

Is there any sort of page limit for a jsp page?

A bit more background: This page works just fine in a WIN2K server running Tomcat 5.5. I'm upgrading this app to run under a server with WIN2008 + Tomcat 6.0. That's where I get the error ...

Any help is appreciated.

Is there any sort of page limit for a jsp page?

AFAIK, no.

I think that the most likely cause is that your JSP is throwing an exception. Check the Tomcat logs, and look at the JSP at the point after the last HTML that was output.

EDIT

@Adam Crume says: "The exception may be thrown at a point further down from where the output stops, due to buffering."

True. As a temporary hack to get around this, you could surround the JSP's content with a try / finally, and flush the output stream in the finally block.

Is there any sort of page limit for a jsp page?

Yes, there is. It's about 64KB. JSP's are basically compiled into a large try statement. In Java, there's a 64KB limit for try statement. But if you exceed this, it would have prouced a different exception .

This problem at least indicates that you're using scriptlets in the JSP. This is a bad practice . Whenever an exception occurs halfway a JSP page, you'll get a blank or halfbaked page without information about the problem. Don't execute business stuff in JSP, but in a preprocessing Servlet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM