aspose file tools*
The moose likes JSP and the fly likes else loop not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "else loop not working" Watch "else loop not working" New topic
Author

else loop not working

anu rani
Greenhorn

Joined: Aug 29, 2006
Posts: 14
i have a program whatever i write the code in else loop it is not working.
String s = request.getParameter("username");
String pass=request.getParameter("password");
out.println("username"+"<br>"+s);
out.println("pass"+"<br>"+pass);
String pwd=null;
Statement st=null;
ResultSet rs=null;
Connection con=null;
ConnectionBean1 cb = new ConnectionBean1();
con = cb.getConnection();

String str="select password,status from login where username='"+ s +"' and password='"+pass+"' ";
out.println(str);
st =con.createStatement();
rs=st.executeQuery(str);

while (rs.next())
{
stat=rs.getString("status");
pwd=rs.getString("password");

}
out.println("stat"+stat);

out.println("pass"+pass);
out.println("pwd"+pwd);

rs.close();
st.close();
con.close();
if(pwd.equals(pass))
{
out.println("successfull login");
response.sendRedirect("../mobile4/view.jsp");
}
else
{
out.println("please try again");
response.sendRedirect("../mobile4/err.jsp");
}


}
catch(Exception exception)
{



out.println(exception.toString());
}
%>
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

suppose, you give wrong username and password,then exception will occured here
right?

then you put yoour else block code into the Catch block.

Hope This Helps
baalu sasidhar
Greenhorn

Joined: Jun 25, 2008
Posts: 4
ARE U GETTING ANY EXCEPTIONS? IF YES CHECK WHAT EXCEPTION ARE U GETTING? LET ME KNOW WHETHER YOUR IF BLOCK IS WORKING?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
Baalu, for all our eyes' sake, please KeepItDown. It looks like you're shouting at us.


Ping & DNS - updated with new look and Ping home screen widget
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2709
    
    5

And BTW else is not a loop.
Please UseAMeaningfulSubjectLine.


SCJP, SCWCD.
|Asking Good Questions|
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: else loop not working
 
Similar Threads
invalid cursor state
problem with code
Help with this code!
html page and servlet interaction Kindly help
How this code can be improved?