|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| Question |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: |
<-------- index.jsp--------------->
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="validateuser.jsp" method="POST">
username - <input type="text" name="userName">
password - <input type="password" name="passWord">
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
</body>
</html>
<----------validateuser.jsp---------------->
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@page import="java.util.*" %>
<%@page import="java.util.HashMap" %>
<%@page import="java.util.Collections" %>
<jsp:useBean id="idHandler" class="com.mycompany.login.Login" scope="request">
<jsp:setProperty name="idHandler" property="*"/>
</jsp:useBean>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head></head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<body>
<%
String userName = request.getParameter("userName");
String passWord = request.getParameter("passWord");
if (idHandler.authenticate(userName, passWord)){
System.out.println("login is successfull");
} else {
response.sendRedirect("retry.jsp");
}
%>
</body>
</html>
<------------------- login.java----------------------->
package com.mycompany.login;
import java.sql.*;
import java.io.*;
public class Login {
//default constructor
public Login(){}
//method for the catabase connection
public Connection getConnection()
throws IOException{
Connection conn = null;
try{
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection(
"jdbc:mysql:@localhost:3036:anantha",
"root",
"buser");
}
catch(SQLException e)
{
System.out.println("SQLException: " + e.getMessage());
while((e = e.getNextException()) != null)
System.out.println(e.getMessage());
}
catch(ClassNotFoundException e)
{
System.out.println("ClassNotFoundException: " + e.getMessage());
}
return conn;
}
//method that is called from validateuser.jsp and this checks for the authentic user and
public boolean authenticate(String user, String pass)
throws SQLException, IOException{
String Username = null;
String Password = null;
Login dbconn = new Login();
Statement stmt = dbconn.getConnection().createStatement();
String sql = "SELECT USER_NAME,PASSWORD FROM userlogin WHERE USER_NAME='" + user + "'" + "AND PASSWORD='" + pass + "'";
ResultSet rs = stmt.executeQuery(sql);
if(rs.next()){
Username = rs.getString("USER_NAME");
Password = rs.getString("PASSWORD");
}
if(Username != null && Password != null && user.equals(Username) && pass.equals(Password)){
//return true;
return (Username != null && Password != null && Username.equals(user) && Password.equals(pass));
}
else return false;
}
}
|
Advertisement
| Hall of Fame |