Here seems to be your problem. Change these String comparisons from == to
.equals()
// build dynamic content
if(interest.equals("")) {
out.println(buildDefault());
}
else if(interest.equals("Procedures ")) {
out.println(buildProcedures());
}
else if(interest.equals("Cafeteria")) {
out.println(buildCafeteria());
}
else if(interest.equals("Maps")) {
out.println(buildMaps());
}
Erik Sahl
[EMAIL PROTECTED]
> -----Original Message-----
> From: A mailing list for discussion about Sun Microsystem's Java Servlet
> API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of
> Jeffrey L. Watson
> Sent: Monday, June 14, 1999 1:48 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Parameter
>
>
> I want to evaluate a parameter called "interest" and build dynamic HTML
> content based on it's value. When I write the value of
> "interest" back out
> to the web page it seems to have the correct parameter value. Lets say if
> called with ?interest=Maps then it writes out to the web page "Maps".
> However, when I try to make a comparison between "interest" and a
> String as
> in the code below, it doesn't work if interest equals anything other than
> "".
>
> For example:
>
> http://server/servlet/dynamic
> This returns the content built in buildDefault()
>
> http://server/servlet/dynamic?interest=Maps
> Doesn't return any content at all.
>
>
> // get initialization parameters
> if (req.getParameter("interest") != null) {
> interest = req.getParameter("interest");
> }
> else {
> interest = "";
> }
>
> // build dynamic content
> if(interest == "") {
> out.println(buildDefault());
> }
> else if(interest == "Procedures ") {
> out.println(buildProcedures());
> }
> else if(interest == "Cafeteria") {
> out.println(buildCafeteria());
> }
> else if(interest == "Maps") {
> out.println(buildMaps());
> }
>
> Thanks!
>
> Jeff
>
> __________________________________________________________________
> _________
> To unsubscribe, send email to [EMAIL PROTECTED] and include
> in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html