Solved

Strange thing

Posted on 2004-03-24
2
178 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
  • 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

A safe way to clean winsxs folder from your windows server 2008 R2 editions
What is Backup? Backup software creates one or more copies of the data on your digital devices in case your original data is lost or damaged. Different backup solutions protect different kinds of data and different combinations of devices. For e…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now