root / trunk / web / login.jsp @ 13
History | View | Annotate | Download (1.98 KB)
| 1 |
<%@page import="net.sf.jpam.Pam"%> |
|---|---|
| 2 |
<%@page contentType="text/html" pageEncoding="UTF-8"%> |
| 3 |
<% |
| 4 |
String error = null; |
| 5 |
String username = request.getParameter("username");
|
| 6 |
String password = request.getParameter("password");
|
| 7 |
if(username != null && password != null){
|
| 8 |
Pam pam = new Pam(); |
| 9 |
boolean auth = pam.authenticateSuccessful(username, password); |
| 10 |
|
| 11 |
if(auth){
|
| 12 |
session.setAttribute("authenticated", true);
|
| 13 |
session.setAttribute("username", username);
|
| 14 |
response.sendRedirect("index.jsp");
|
| 15 |
} else {
|
| 16 |
error = "Wrong username and/or password!"; |
| 17 |
} |
| 18 |
} |
| 19 |
%> |
| 20 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
| 21 |
"http://www.w3.org/TR/html4/loose.dtd"> |
| 22 |
|
| 23 |
<html> |
| 24 |
<head> |
| 25 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| 26 |
<title>JSP Page</title> |
| 27 |
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.8.1/build/reset-fonts-grids/reset-fonts-grids.css"/> |
| 28 |
<link href="css/login.css" media="screen" rel="stylesheet" type="text/css"/> |
| 29 |
</head> |
| 30 |
<body> |
| 31 |
<div class="wrap"> |
| 32 |
<div class="form clearfix"> |
| 33 |
<h1>Login</h1> |
| 34 |
<form id="login" action="login.jsp" method="post"> |
| 35 |
<div> |
| 36 |
<label>Username</label> |
| 37 |
<input type="text" name="username" id="username" class="wide" value=""> |
| 38 |
</div> |
| 39 |
<div> |
| 40 |
<label>Password</label> |
| 41 |
<input type="password" name="password" id="password" class="wide"> |
| 42 |
</div> |
| 43 |
<div class="clearfix button-container"> |
| 44 |
<div class="button large"><input id="submit" type="submit" value="Login"></div> |
| 45 |
</div> |
| 46 |
<% if(error != null){ %>
|
| 47 |
<div class="clearfix"> |
| 48 |
<div class="error"><%= error %></div> |
| 49 |
</div> |
| 50 |
<% } %> |
| 51 |
</form> |
| 52 |
</div> |
| 53 |
</div> |
| 54 |
</body> |
| 55 |
</html> |