packagecom.roshka.proyectofinal;importjava.io.*;importjava.util.*;importjavax.servlet.*;importjavax.servlet.http.*;publicclassProtectedResourceextendsHttpServlet{publicvoiddoGet(HttpServletRequestreq,HttpServletResponseres)throwsServletException,IOException{res.setContentType("text/plain");PrintWriterout=res.getWriter();// Get the sessionHttpSessionsession=req.getSession(true);// Does the session indicate this user already logged in?Objectdone=session.getValue("logon.isDone");// marker objectif(done==null){// No logon.isDone means he hasn't logged in. // Save the request URL as the true target and redirect to the login pagesession.putValue("login.target",HttpUtils.getRequestURL(req).toString());res.sendRedirect(req.getScheme()+"://"+req.getServerName()+":"+req.getServerPort()+"/login.html");return;}// If we get here, the user has logged in and can see the goodsout.println("Unpublished O'Reilly book manuscripts await you!");}}