wood burning stoves*
The moose likes Struts and the fly likes struts examples using mysql like loginscreen Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts examples using mysql like loginscreen" Watch "struts examples using mysql like loginscreen" New topic
Author

struts examples using mysql like loginscreen

sherin pooja
Greenhorn

Joined: Apr 20, 2006
Posts: 1
This coding is used for only jsp page like login screen. Now i want to use this coding in struts and mysql. i know struts little. I don't know exactly how to send text box values in action page, form and database. will u please help me how can i use this coding in struts. please give me coding in struts or forward my id sherin_rakin@yahoo.co.in

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 aram name="errMsg"
value="Sorry Your UserName and Password is Mismatch" />
</jsp:forward>
<% } %>

bye
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: struts examples using mysql like loginscreen