You've defined the variable strOutput within a limited scope (those brackets
immediately following the strHeader.equals(strCompare) evaluation) so it
doesn't exist by the time you get to the bottom.  Try this:

String strOutput = null;
if (strHeader.equals(strCompare)) {
  strOutput = "http://www.amazon.com/";;
} else {
  strOutput = "http://www.bn.com/";;
}

or

String strOutput = (strHeader.equals(strCompare)) ? "http://www.amazon.com/";
: "http://www.bn.com/";;

(As an aside, I know the guy who owns the test.com domain, and you wouldn't
believe how many test emails/traffic/etc. he gets from developers who use
that domain when they're developing.)

> -----Original Message-----
> From: Alex Nguyen [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 17, 2001 12:56 PM
> To: [EMAIL PROTECTED]
> Subject: Newbie Variable Question
>
>
> Can anyone tell me why this
> gets this error:
>
> 500 Servlet Exception
> /Alex/footer.jsp:18: Undefined variable: strOutput
>       out.print((strOutput));
>                  ^
> 1 error
>
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to