hi guys >> i need ur help please >>> i ve created a login page which includes user name and password and i created a welcome page which contains the required codes for connection and verifying the username and password from oracle database .. when i run the login page and entering the username and password there is no outputs (seems no connection ).
here are the codes for login page
<%@ page contentType="text/html;charset=windows-1256"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<html>
<head>
</head>
<body>
<br><br><br>
<table align="center" width="400px" border=0>
</table>
<table align="center"><tr><td colspan=2><h1>User Login</h2></h1></td></tr></table>
<form name="loginform" method="post" action="welcome.jsp" >
<table align="center" width="300px" style="border:1px solid #000000;" >
<tr><td colspan=2> </td></tr>
<tr>
<td><b>Login Name</b></td>
<td><input type="text" name="userName" value=""></td>
</tr>
<tr>
<td><b>Password</b></td>
<td><input type="password" name="password" value=""></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
<tr><td colspan=2> </td></tr>
</table>
</form>
</body>
</html>
here the codes for the welcome page
<%@ page contentType="text/html;charset=windows-1256"%>
<%@ page language="java" import="java.sql.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256"></meta>
<title>untitled</title>
</head>
<body>
</body>
<%
String user=request.getParameter("userName");
String pass=request.getParameter("password");
try{
java.lang.Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@127.0.0.1:1521:orcl", "sourcepad", "s");
Statement st=conn.createStatement();
ResultSet rs=st.executeQuery("select username,password from user_tab");
while(rs.next()){
String username=rs.getString(1);
String password=rs.getString(2);
if (user.equals("username") && pass.equals("password")) {
out.println("<a href=\"welcome.jsp\"> </a>");
}
else
out.println("Login Failed,Please try Againe");
}}
catch(Exception e1)
{}
%>
</html>