Example usage for javax.servlet RequestDispatcher include

List of usage examples for javax.servlet RequestDispatcher include

Introduction

In this page you can find the example usage for javax.servlet RequestDispatcher include.

Prototype

public void include(ServletRequest request, ServletResponse response) throws ServletException, IOException;

Source Link

Document

Includes the content of a resource (servlet, JSP page, HTML file) in the response.

Usage

From source file:io.muic.ooc.webapp.servlet.LogoutServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    securityService.logout(request);/*from   w  w w . j  a  v  a 2  s . co  m*/
    RequestDispatcher rd = request.getRequestDispatcher("WEB-INF/login.jsp");
    rd.include(request, response);
}

From source file:BookListXMLJSPServlet.java

protected void service(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    List bookList = BookListFactory.INSTANCE;

    request.setAttribute("bookList", bookList);
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/booklist1.jsp");
    dispatcher.include(request, response);
}

From source file:IncludeServlet.java

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, java.io.IOException {

    response.setContentType("text/html");
    java.io.PrintWriter out = response.getWriter();

    out.println("<html>");
    out.println("<head>");
    out.println("<title>Include Servlet</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h1>Welcome To Our Universe</h1>");
    out.println("Imagine the rest of the page here.<br><br>");
    //Include the copyright information
    RequestDispatcher dispatcher = request.getRequestDispatcher("/CopyRight");
    dispatcher.include(request, response);

    out.println("</body>");
    out.println("</html>");

    out.close();/* w  w w .  jav a2  s .c  o m*/

}

From source file:org.jboss.dashboard.ui.controller.responses.ShowScreenResponse.java

public boolean execute(CommandRequest cmdReq) throws Exception {
    if (log.isDebugEnabled())
        log.debug("ShowScreenResponse: " + jsp);
    RequestDispatcher rd = cmdReq.getRequestObject().getRequestDispatcher(jsp);
    rd.include(cmdReq.getRequestObject(), cmdReq.getResponseObject());
    return true;/* w  w w .  ja v  a 2 s.c om*/
}

From source file:io.muic.ooc.webapp.servlet.EditServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String username = request.getParameter("usernameEditFirst");
    request.setAttribute("username", username);
    RequestDispatcher rd = request.getRequestDispatcher("WEB-INF/edit.jsp");
    rd.include(request, response);
}

From source file:org.jboss.dashboard.ui.controller.responses.ShowPopupPage.java

/**
 * Executes the response. It typically will be one of the response types
 * that are provided in the org.jboss.dashboard.ui.controller.responses package.
 *
 * @param cmdReq Object encapsulating the request information.
 * @return boolean if the execution has been successfuly executed, false otherwise.
 *///from w  ww . j a  v a  2  s  .co m
public boolean execute(CommandRequest cmdReq) throws Exception {
    cmdReq.getResponseObject().setHeader("Content-Encoding", HTTPSettings.lookup().getEncoding());
    cmdReq.getResponseObject().setContentType(contentType + ";charset=" + HTTPSettings.lookup().getEncoding());
    RequestDispatcher rd = cmdReq.getRequestObject().getRequestDispatcher(page);
    rd.include(cmdReq.getRequestObject(), cmdReq.getResponseObject());
    return true;
}

From source file:io.muic.ooc.webapp.servlet.LoginServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    RequestDispatcher rd = request.getRequestDispatcher("WEB-INF/login.jsp");
    rd.include(request, response);
}

From source file:io.muic.ooc.servlet.LoginServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    if (SecurityService.isAuthorized(request)) {
        response.sendRedirect("/home");
    } else {/* w w  w .j a  v a 2 s .  c om*/
        RequestDispatcher rd = request.getRequestDispatcher("/WEB-INF/login.jsp");
        rd.include(request, response);
    }
}

From source file:io.muic.ooc.webapp.servlet.RegisterServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    RequestDispatcher rd = request.getRequestDispatcher("WEB-INF/signup.jsp");
    rd.include(request, response);
}

From source file:org.jboss.dashboard.ui.controller.responses.FullPanelAjaxResponse.java

public boolean execute(CommandRequest cmdReq) throws Exception {
    Panel panel = getPanel();/*from w w  w .  j a  v a2 s  .  c o  m*/
    if (log.isDebugEnabled())
        log.debug("FullPanelAjaxResponse: " + panel.getFullDescription());
    cmdReq.getResponseObject().setHeader("Content-Encoding", HTTPSettings.lookup().getEncoding());
    cmdReq.getResponseObject().setContentType("text/html;charset=" + HTTPSettings.lookup().getEncoding());
    cmdReq.getRequestObject().setAttribute(Parameters.RENDER_PANEL, panel);
    PanelSession pSession = SessionManager.getPanelSession(panel);
    pSession.setCurrentPageId(page);
    RequestDispatcher rd[] = { cmdReq.getRequestObject().getRequestDispatcher(commonRefreshPanelsPage),
            cmdReq.getRequestObject().getRequestDispatcher(beforePanelsPage),
            cmdReq.getRequestObject().getRequestDispatcher(panel.getProvider().getPage(page)),
            cmdReq.getRequestObject().getRequestDispatcher(afterPanelsPage) };
    panel.getProvider().getDriver().fireBeforeRenderPanel(panel, cmdReq.getRequestObject(),
            cmdReq.getResponseObject());
    for (int i = 0; i < rd.length; i++) {
        RequestDispatcher requestDispatcher = rd[i];
        requestDispatcher.include(cmdReq.getRequestObject(), cmdReq.getResponseObject());
    }
    panel.getProvider().getDriver().fireAfterRenderPanel(panel, cmdReq.getRequestObject(),
            cmdReq.getResponseObject());
    return true;

}