Java Reference
In-Depth Information
<%@ page contentType # "text/html" language # "java" %>
<%@ page import # "UbiMail.*" %>
<%
Manager manager # (Manager)application.getAttribute
("manager");
String name # request.getParameter("login");
String pass # request.getParameter("pass");
// authenticate the user
User user # manager.authenticate(name,pass);
if (user! # null ){
// register the user in the session context
session.setAttribute("user",user);
// redirect the browser to the main page
response.sendRedirect("main.jsp");
} else {
// close the session and show an error message
session.invalidate();
%>
<html>
<head><title> UbiMail - failed login </title></head>
<body><h1> UbiMail </h1>
Sorry user not existent or password incorrect.
<br><i><% # manager.getError() %></i>
<p> To try again go to <a href # "index.html" >
login page </a> .
</body></html>
<% } %>
The JSP main displays a list of the messages, exactly as in the previous
prototype. The difference lies in the way this page gets access to the mail
server. In this prototype the User class mediates the access to the server and
returns the main folder. As a result the JSP is much simpler. We present here
only the parts that are different from the previous version.
<%@ page contentType # "text/html" language # "java" %>
<%@ page import # "javax.mail.*, java.util.Properties,
java.util.Enumeration" %>
<%@ page import # "UbiMail.*" %>
<%
User user # (User)session.getAttribute("user");
if (session.isNew() || user ## null ){
response.sendRedirect("index.html");
return ;
}
%>
<html>
<head><title> UbiMail - <% # user.firstName() %>
<% # user.lastName() %> 's mailbox </title></head>
Search WWH ::




Custom Search