--- Bob Bateman <[EMAIL PROTECTED]> wrote:

> On Fri, 4 Nov 2005 11:14:19 -0800 (PST)
>   Dola Woolfe <[EMAIL PROTECTED]> wrote:
> > Hi,
> > 
> > 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
> > seconds>");
> >  // 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.
> 
> I would postulate that you are executing unnecessary
> code.
> 
> *Disclaimer: The following is NOT compliant with MVC
> best 
> practices...
> 
> In your JSP page, you *probably* want your "if 
> (display-nothing-only-forward)" statement to execute
> if 
> there is nothing to do.  If that is true, then after
> your 
> closing brace with the META info in it, you probably
> want 
> to use an 'else' clause and enclose the rest of your
> code 
> in a set of braces.
> 
> In effect, what you've done is to tell the system to
> put 
> the META statement out ONLY when there is nothing
> else to 
> do - but the rest of your code runs all the time.
> 
> If you have sufficient experience, I would suggest 
> removing all of the java code from your JSP page and
> 
> putting the code into a Tag.  Tags are really easy
> to use 
> and keep your business logic seperate from your JSP 
> presentation.  Of course, you'll still have to
> generate 
> HTML in the Tag, but that's partly what tags are
> for.
> 
> Bob
> 
Hi Bob, 

I have not used Tags and plan to take a look at them
soon.

Concerning the rest of your suggestion, having a big
"else" clause is precisely something I'm trying to
avoid. I always prefer

if (short_clause) {
  //...
  return;
}

//rest of code

to 

if (short_clause) {
  //...
  return;
}
else {
//rest of code
}

Also, what I'm curious about is this; what I do may
not be a good coding practice, but what is causing the
error?

Thanks!

Dola


>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 
> 



                
__________________________________ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to