Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Error in <jsp:usebean>  RSS feed

 
er gerg
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends .. i am new to jsp .. please help me out .. I am getting ." Fail" in the end .. tell me where i gone wrong.....

LOGIN.HTML

<form action="login.jsp" >
<TABLE>
<TR>
<TD><input type="text" name="username"></TD>
</TR>
<TR>
<TD><input type="password" name="userpass"></TD>
</TR>
<TR>
<TD ><input type="submit" name="Submit" value="Submit"></TD>
</TR>
</TABLE>
</form>


LOGIN.JSP

<jsp:useBean id="useLoginBean" scope="request" class="vcs.LoginBean" />
<jsp:setProperty name="useLoginBean" property="urid" param="username"/>
<%
if(useLoginBean.check()==0) {
out.println("Done");
}
else if(useLoginBean.check()==0) {
out.println("not match");
}
else {
out.println("fail");
}
%>


LOGINBEAN.JAVA

package vcs;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class LoginBean {

String urid, urpass, urlevel, urblock;

public String getUrblock() {
return urblock;
}

public void setUrblock(String urblock) {
this.urblock = urblock;
}

public String getUrid() {
return urid;
}

public void setUrid(String urid) {
this.urid = urid;
}

public String getUrlevel() {
return urlevel;
}

public void setUrlevel(String urlevel) {
this.urlevel = urlevel;
}

public String getUrpass() {
return urpass;
}

public void setUrpass(String urpass) {
this.urpass = urpass;
}



public int check() {
String pwd=null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbcracle:thin:@localhost:1521:xe", "system", "manager");
String sql = "SELECT urpass FROM SYSTEM.USERLOG WHERE urid = '" + urid + "' AND urblock= 0";
Statement state = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet res = state.executeQuery(sql);
while (res.next()) {
pwd = res.getString("urpass");
}
con.close();


} catch (Exception e) {
System.out.println(e);
}
if(pwd!=null) {
if ((urpass).equals(pwd)) {
return 0;
}
else
return 1;

}
return -1;
}
}





URID URPASS URLEVEL URBLOCK
rohan abc 0 0
braj xyz 1 0
anoop abc 2 0
ashwin xyz 3 0


 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the button on your post.
 
Aman Goel
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use the same name in bean class as per login form name..... e.g. use "username" for username in both login.html and loginbean.java
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!