This discussion is archived
5 Replies Latest reply: Apr 19, 2006 9:22 PM by 843844 RSS

login screen in struts and mysql database

843844 Newbie
Currently Being Moderated
This coding is used for only jsp page like login screen. Now i want to use this coding in struts and mysql. will u please help how can i use this coding in struts. please help me

Index.jsp
Admin : <input type="text" name="admin_name" size="22" value="">
Password : <input type="password" name="admin_password" size="22">

<input value="Login" name="login" type="submit" value="Login">
<input value="Cancel" name="login" type="submit" value="Cancel">

admincheck.jsp
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection
("Jdbc:mysql://localhost:3306/domaininform","root","");
String admnName = request.getParameter("admin_name") ; // Get
the User Name
String admnPwd = request.getParameter("admin_password") ;
statement = conn.createStatement();
String Query = ("select * from admin " ) ;
rs = statement.executeQuery(Query);
while(rs.next())
{
admn = rs.getString(1);
pwd = rs.getString(2);
}
if( (admnName.equals(admn)) && (admnPwd.equals(pwd)))
{ %>
<jsp:forward page="selectTable.jsp?butType=normal"/>
<% } %>
<% if( (admnName != admn) && (admnPwd !=pwd ))
{   %>
<jsp:forward page="index.jsp">
<jsp:param name="errMsg"
value="Sorry Your UserName and Password is Mismatch" />
</jsp:forward>
<% } %>