Hello Sir,
Create javabean as follows:
// Assign page name, very important
package example.test;
public class LoginCheck {
private
String userName = "";
private String passWord = "";
// Default constructor is required.
public LoginCheck() { }
// JavaBean needs setter and getter methods
public void setUserName(String user) {
this.userName = user;
}
public void setPassWord(String passWord) {
this.passWord = passWord;
}
// You can define a method here with
// your database connection details.
public boolean authenticate(String user) {
return (this.username.equalsIgnoreCase(this.userName));
}
}
You can use a JavaBean as follows in a JSP:
<jsp:useBean id="loginBean"<br /> scope="page"<br /> class="example.test.LoginCheck">
<jsp:setProperty name="loginBean" property="*"/>
</jsp:useBean>
<%<br /> // You can call and use a JavaBean as follows:<br /> boolean isLoggedIn = loginBean.authenticate("RanchHand");<br /> %>
Hope this helps.
Cheers
Originally posted by vinu pillai:
hi all,
How to make a bean for connecting to Database through JSP..???
I have no idea what bean are....i hard code the jdbc syntaxes in the scriptlet tag itself...but some say that making a connection bean is proper way to show the database results...
i don't know how to create bean ...can help me out to find the best tutorial links to JavaBeans..
Thanks..
VINU