Struts Code:
action name="alreadylogin" class="struts.alreadylogin"
result name="success">/indexlogin.jsp</result>
<result name="error">/failure.jsp</result>
<result name="input">/login.jsp</result>
</action>
Java Class Code:
public String loginemail;
String loginpassword;
public String execute() {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager
.getConnection("jdbc:oracle:thin:system/hr@localhost:1521:XE");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from logininfo");
while (rs.next()) {
String lemail = rs.getString(3);
String lpassword = rs.getString(4);
if(lemail.equals(loginemail)&&(lpassword.equals(loginpassword)))
return "success";
}
}
catch(SQLException s)
{
return "error";
}
catch(ClassNotFoundException c)
{
return "error";
}
It shows the error to Insert Finally into the code or return a String. If I use finally, the return statement will execute no matter what which destroys the purpose of checking for a user to log in.