permaculture playing cards*
The moose likes JSP and the fly likes PLZ tell me ,what's wrong in it???? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "PLZ tell me ,what Watch "PLZ tell me ,what New topic
Author

PLZ tell me ,what's wrong in it????

Sura Lin
Greenhorn

Joined: Feb 22, 2002
Posts: 6
String ss=request.getParameter("select");
if(ss=="*"){ss="all";}
can you tell me why (ss="all") is not execute when ss's value is "*"

thanks


bull
gautam shah
Ranch Hand

Joined: Oct 29, 2000
Posts: 72
Originally posted by Sura Lin:
String ss=request.getParameter("select");
if(ss=="*"){ss="all";}
can you tell me why (ss="all") is not execute when ss's value is "*"

thanks

try
if(ss.equals("*"))
{ss="all";}
object references of String literals can't be compared in this way to get desired results. this kind of comparision is also possible but that is a another story..

ooops i forgot that i have to finished my PPL book as soon as possible to clear my concepts regarding variable and objects. let me Run...
Brian Glodde
Ranch Hand

Joined: Jun 27, 2001
Posts: 171
String ss = ( String) request.getParameter("select");
if( ss == null ) ss = "";
// now you can evaluate ss
if( ss.equals("*") ) ss = "all";
// if ss contained "*" then it should now
// be "all"
Sura Lin
Greenhorn

Joined: Feb 22, 2002
Posts: 6
Thanks.Your reply is very useful.
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Hi,
String ss = ( String) request.getParameter("select");

This cast is unnecessary since getParameter() always returns a String.
-anthony
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: PLZ tell me ,what's wrong in it????
 
Similar Threads
Auxiliary files
EJB and JDBC
Auxiliary files
collations on SQL server
J++