Java Reference
In-Depth Information
L ISTING 9.1
Continued
}
response.setContentType(“text/html”);
PrintWriter out = response.getWriter();
out.println(“<html>”);
out.println(“<head><title>Roll Your Own</title></head>”);
out.println(“<body>”);
if ( valid == true ) {
// Successful validation, redirect to the GET method
// of this servlet
response.sendRedirect(“/djs/servlet/” +
“RollYourOwnSecurityServlet”);
}
else {
out.println(“We don't know who you are please leave!”);
}
out.println(“</body></html>”);
out.close();
}
//Get Servlet information
public String getServletInfo() {
return “RollYourOwnSecurityServlet Information”;
}
}
This is a simple example of implementing your own security model. The first step is to display
the login form when the user accesses the Web site. The HTML source for the login screen is
in Listing 9.2.
L ISTING 9.2
LoginScreen.html
<HTML>
<HEAD>
<TITLE>
Login Screen
</TITLE>
</HEAD>
Search WWH ::




Custom Search