tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Darryl L. Miles" <>
Subject Re: Can a "return" statement cause a problem?
Date Sat, 05 Nov 2005 13:16:14 GMT

Dola Woolfe wrote:

>In one of my JSP pages (ErrorPage.jsp) I have the
>following code.
>if (display-nothing-only-forward) {
>  out.println("<META to forward to another page in 0
>  // return;
>//Lot's more code
>It works, but prints out unnecessary html before it
>forwards. But if I uncomment "return" it stops
>working. I get
>HTTP 500 - Internal server error 
>What could that be? In the tomcat console window, I
>get no indication that something is not right.

First you still should be presenting a well formed HTML page to the 
browser.  I think I'm correcting in stating that <META ...> should 
exiting inside <HEAD>, but you still should emit 

Second are you sure you want to do your HTTP redirect like this ?   
Conceptually by the time you are rendering a JSP page your that Servlet 
has made a decision that this JSP page (and therefore this View) is the 
correct one the user should see.  I am presuming that you might not have 
any customer Servlet infront of this JSP page and are using the 
defaultServlet to get there.  Maybe its worth you creating a Servlet and 
moving the Java Code logic into that.  Then doing a "forward" to the JSP 
page you wish to render, or setup a HTTP redirect to force the browser 
to goto another URL.

My thoughts.

I'm not sure if return is right or wrong here from a specification 

Darryl L. Miles

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message