• Post Reply Bookmark Topic Watch Topic
  • New Topic

querystring value

 
Piyush Daiya
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
this is problem im facing:-
im opening page index.jsp?errmsg=true
index.jsp
---------

<%
String msg="";
String errmsg1="";
errmsg1 = (String)request.getParameter("errmsg");
msg = msg + errmsg1;
if(errmsg1=="true"){
msg="Invalid User or Password";
}
%>
<%=msg%>
-------
The if condition is not getting called.
Any pointers?
Piyush
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try:

In Java, the == operator is a test for object identity, not value equality, so you need to use the equals() method.
And by placing the string constant first, you don't need to worry about whether errmsg1 is null or not.
hth,
bear
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!