have you tried:
if(interest.equals("string")){
// out.println("A match!");
}
Use equals(), otherwise you're comparing references to String objects.
"Jeffrey L. Watson" wrote:
> 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