Java Reference
In-Depth Information
L ISTING 5.11 Continued
public class LicenseServlet extends HttpServlet {
/**
* Initialize global variables
*/
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
/**
* Process the HTTP Get request
*/
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
String id = unscramble(request.getParameter(“license-id”));
String pwd = unscramble(request.getParameter(“license-pwd”));
Boolean outcome = new Boolean(check(id, pwd));
response.setContentType(“text/html”);
response.addHeader(“outcome”, outcome.toString());
PrintWriter out = response.getWriter();
if (outcome.booleanValue()){
out.println(“Congratulations for registering your copy!”+
“ Thank You for your choice. Please visit our Web site.”);
} else {
out.println(“Sorry. License Not Valid.”);
out.println(“Please Try Again.”);
}
}
/**
* Clean up resources
*/
public void destroy() {
}
/**
* un-scramble a string
*/
private String unscramble(String s) {
return s;
}
Search WWH ::




Custom Search