tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Slater <djsla...@bellsouth.net>
Subject Re: Checking with DB
Date Sat, 23 Feb 2002 06:54:48 GMT
Not sure how this is Tomcat related other than it looks like you are 
working on a servlet, but what the hell:

Of course !rs.next() would work, as in return 'you are lucky', cause 
I'll bet it's null/empty.

Try System.out.println'ing the request params after getting them into 
the Strings, and construct the SQL command string and println it too 
before it gets used at the query line.  Then you can at least see a 
little what is going on internally.  Could be case, spaces, etc hosing 
you up here.  Never use request params without checking them for null or 
invalid values first.  And don't use *, specify the field names, it 
won't help here but is good practice.


Uma Maheswar wrote:
> Hi,
> Please help me with this. Please see the code below. It doesn't work, if I give the correct
id and password.But it works if I say (!rs.next()). The same type of programme worked for
me in case of other tables. Could any one pls help me solve this problem.
> 
>    String id = req.getParameter("userid");
>    String pwd = req.getParameter("password");
>    
>    ServletOutputStream sos = res.getOutputStream();
>    rs = st.executeQuery("select * from uma where userid='"+user+"' and password='"+pwd+"'
");
>    sos.println("<html><body bgcolor=lightyellow>");
> 
>    if(rs.next())
>    {
> 
> sos.println("you are lucky");   
> sos.println("<input type='submit' value='Submit' name='submit'></p>");
>    }
>    else
>    {
>     sos.println("<h2>Get out of my site</h2>");
>    }
>    sos.println("</body></html>");
>  
>   
>   }
>   catch(Exception e)
>   {
>    e.printStackTrace();
>   }
>  }
> }
> 
> 
> 




--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message