FileDocCategorySizeDatePackage
Controller.javaAPI DocExample1275Mon Feb 09 14:56:34 GMT 2004com.jspservletcookbook

Controller

public class Controller extends HttpServlet

Fields Summary
Constructors Summary
Methods Summary
public voiddoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)


        RequestDispatcher dispatcher = null;
        String param = request.getParameter("go");
             if (param == null)
                 throw new 
                     ServletException("Missing parameter in Controller.");
             else if (param.equals("weather"))
                 dispatcher = getServletContext().
                     getNamedDispatcher("Weather");
             else if (param.equals("maps"))
                 dispatcher = getServletContext().
                     getNamedDispatcher("Maps");
            else
                throw new ServletException(
                    "Improper parameter passed to Controller.");
         /*check for a null dispatcher, then 
            dispatch the request to the correct URL*/
        if (dispatcher != null)
            dispatcher.forward(request,response);
        else
            throw new ServletException(
              "Controller received a null dispatcher.");