Link to home
Start Free TrialLog in
Avatar of princehyderabad
princehyderabad

asked on

find USERID error in JSP

hi experts,

I have jsp which call itself and check certain condition and displays record. If I search by userid, it shows me correct record
<%
if (request.getParameter.equals("Y"))
{
  String getUserId = request.getParameter("userid");
...
..
sb.append(" AND UPPER(USERID) LIKE UPPER('"+getUserId+any+"')");
...
..
rs= stmt.executeQuery(sb.toString());
..
while (rs.next())
 {
...
 }
}
%>

worked fine. Now I added condition if no userid exist display msg. "No users to display". If I type wrong ID it does display msg. But when I type correct ID I'm not getting the record display nor do I'm getting error. Seems like logic error after adding that if (!rs.next())

<%
if (request.getParameter.equals("Y"))
{
  String getUserId = request.getParameter("userid");
...
..
sb.append(" AND UPPER(USERID) LIKE UPPER('"+getUserId+any+"')");
...
..
rs= stmt.executeQuery(sb.toString());
..
if(!rs.next())
        {
          out.print("No users to display");                
        }  
while (rs.next())
 {
...
 }
}
%>


Thx.
PH
ASKER CERTIFIED SOLUTION
Avatar of Peter Kwan
Peter Kwan
Flag of Hong Kong image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of princehyderabad
princehyderabad

ASKER

It returns ONE row if userID matchs exactly the same. But if I search for userID 'a'  all userID starting with 'a' will be displayed. If I search "XYZ" then only one row is return where userId=XYZ