Solved

Strange thing

Posted on 2004-03-24
2
182 Views
Last Modified: 2010-04-01
Hi Experts,

I have simple code in JSP:

String idText = request.getParameter( "id" );

        if ( idText == "test" )
        {
           out.println( "searching in test" );
        }
        else
        {
           out.println( "searching in prod" );
        }

for some reason it always go to  out.println( "searching in prod" ); even when I have "test" in idText.

Please help.
0
Comment
Question by:fpoyavo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 8

Expert Comment

by:william_jwd
ID: 10668183
you should change the code to
String idText = request.getParameter( "id" );

        if ( idText.equals("test") )
        {
           out.println( "searching in test" );
        }
        else
        {
           out.println( "searching in prod" );
        }
0
 
LVL 8

Accepted Solution

by:
william_jwd earned 500 total points
ID: 10668189
you can also use, equalsIgnoreCase if you want to compare ignoring case

String idText = request.getParameter( "id" );

        if ( idText.equalsIgnoreCase("test") )
        {
           out.println( "searching in test" );
        }
        else
        {
           out.println( "searching in prod" );
        }
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
xjc and jaxb 2 95
squirrelPlay java challenge 40 159
Prevent Firefox page from going to the background when clicking a spreadsheet link 17 71
DTD and JAVA versions 1 32
Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question