My Bean
Package dB;
Import java. SQL .*;
Import java. Io .*;
Import java. util .*;
Public class dbconn {
String sdbdriver = "com. Microsoft. JDBC. sqlserver. sqlserverdriver ";
String url = "JDBC: Microsoft: sqlserver: // localhost: 1433; databasename = disc ";
String user = "sa ";
String Password = "20263588 ";
Statement stmt = NULL;
Connection conn = NULL;
Resultset rs = NULL;
Public dbconn (){
Try {
Class. forname (sdbdriver). newinstance ();
System. Out. println ("database driver loaded successfully ");
}
Catch (exception E)
{
E. printstacktrace ();
}
}
Public resultset executequery (string SQL ){
Try {
Conn = drivermanager. getconnection (URL, user, password );
Statement stmt = conn. createstatement (resultset. type_scroll_sensitive, resultset. concur_updatable );
System. Out. Print ("database connected successfully ");
Rs1_stmt.exe cutequery (SQL );
}
Catch (sqlexception ex ){
System. Err. println (ex. getmessage ());
}
Return Rs;
}
Public void executeupdate (string SQL ){
Stmt = NULL;
Rs = NULL;
Try {
Conn = drivermanager. getconnection (URL, user, password );
Statement stmt = conn. createstatement (resultset. type_scroll_sensitive, resultset. concur_updatable );
Stmt.exe cutequery (SQL );
Stmt. Close ();
Conn. Close ();
}
Catch (sqlexception ex ){
System. Err. println (ex. getmessage ());
}
}
Public void closestmt ()
{
Try {
Stmt. Close ();
}
Catch (sqlexception E)
{
E. printstacktrace ();
}
}
Public void closeconn ()
{
Try {
Conn. Close ();
}
Catch (sqlexception E)
{
E. printstacktrace ();
}
}
}
Login_confirm.jsp code
<% @ Page contenttype = "text/html; charset = gb2312" %>
<HTML>
<Head>
<Title> logon verification </title>
</Head>
<Body>
<% @ Page Language = "Java" Import = "Java. SQL. *, java. util. *, java. Lang. *" %>
<JSP: usebean id = "conndbbean" Scope = "page" class = "DB. dbconn"/>
<%
String name1 = new string (request. getparameter ("user_id"). getbytes ("ISO-8859-1 "));
String pwd1 = new string (request. getparameter ("password"). getbytes ("ISO-8859-1 "));
String SQL = "select * from ADM where name = '" + name1 + "' and Password = '"
+ Pwd1 + "'";
Resultset rs1_conndbbean.exe cutequery (SQL );
If (Rs. Next ()){
Rs. Close ();
Conndbbean. closestmt ();
Conndbbean. closeconn ();
Session. putvalue ("username", name1 );
Session. putvalue ("password", pwd1 );
%>
<Script language = JavaScript>
Window. Location = "index_ OK .jsp? Mark = dfsd"
</SCRIPT>
<%}
Else {
Rs. Close ();
Conndbbean. closestmt ();
Conndbbean. closeconn ();
Session. putvalue ("login_message", MSG );
%>
<JSP: foward page = "relogin. jsp"/>
<% }%>
</Body>
</Html>
Question added:SOS submission form Section
<Form action = "login_confirm.jsp" method = "Post" name = "form1">
<TD width = "62" align = "Left"> <Div align = "center"> User Name </div> </TD>
<TD width = "181"> <input name = "user_id" type = "text"> </TD>
<TD width = "48" align = "Left"> <Div align = "center"> password </div> </TD>
<TD width = "168"> <input type = "password" name = "password"> </TD>
<TD colspan = 2 align = "center">
<Input type = "button" value = "login" onclick = "Submit ()" size = "4";> </TD>
<TD width = "129" colspan = "2" align = "right"> <a href = "register. jsp">
<Input type = "reset" value = "cancel" size = "4"/>
<SPAN class = "style29"> New Member registration </span> </a> </TD>
</Tr>
<%
String getloginmessage = (string) Session. getvalue ("loginsign ");
If (getloginmessage! = "OK ")
{
%>
<Tr>
<TD colspan = 2>
<Div align = "center"> </div>
</TD>
</Tr>
<%
}
Else {
%>
<Tr>
<TD colspan = 2 align = "center">
<A href = "change_infor.jsp"> modify
</A>
</TD>
</Tr>
<%
}
%>
</Table>
</Form>
</Div>
</Body>
</Html>