FileDocCategorySizeDatePackage
BookStoreServlet.javaAPI DocExample1990Tue Dec 12 18:59:38 GMT 2000None

BookStoreServlet

public class BookStoreServlet extends HttpServlet
An HTTP Servlet that overrides the service method to return a simple web page.

Fields Summary
Constructors Summary
Methods Summary
public java.lang.StringgetServletInfo()

        return "The BookStore servlet returns the main web page " +
               "for Duke's Bookstore.";
    
public voidservice(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

        // Get the dispatcher; it gets the main page to the user
        RequestDispatcher dispatcher =
            getServletContext().getRequestDispatcher(
                "/bookstore/bookstore.html");

        if (dispatcher == null) {
System.out.println("There was no dispatcher");
            // No dispatcher means the html file could not be found.
            response.sendError(response.SC_NO_CONTENT);
        } else {
System.out.println("There is a dispatcher");
            // Get or start a new session for this user
            HttpSession session = request.getSession();
            // Send the user the bookstore's opening page
            dispatcher.forward(request, response);
        }