• Post Reply Bookmark Topic Watch Topic
  • New Topic

Cannot compare string with request.getParameter  RSS feed

 
Gaurav x Jain
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends

I just want to compare following code:

<%
int x,y;
x=0;
y=8;
String sel=request.getParameter("fromcur");

String sel1=request.getParameter("tocur");

if(sel=="INR")
{
%>
<%= x%>
<%
}else {

%>
<%= y%>
<%
}
%>

It always false the condition when I select INR from combo box(sel)

Please help me.
 
Gaurav x Jain
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it's working with use of .equals operator
 
Ankit Tripathi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should work in second case because in first case you were checking against the equality of references which are pointing to respective strings.In second case you are checking against the content of Strings.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!