Example usage for javax.servlet ServletContext getRequestDispatcher

List of usage examples for javax.servlet ServletContext getRequestDispatcher

Introduction

In this page you can find the example usage for javax.servlet ServletContext getRequestDispatcher.

Prototype

public RequestDispatcher getRequestDispatcher(String path);

Source Link

Document

Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path.

Usage

From source file:com.ikon.servlet.admin.ConfigServlet.java

/**
 * Create config/*w  w w .  j  a  v  a 2s  .  co  m*/
 */
private void create(String userId, Map<String, String> types, HttpServletRequest request,
        HttpServletResponse response) throws ServletException, IOException, DatabaseException {
    ServletContext sc = getServletContext();
    Config cfg = new Config();
    sc.setAttribute("action", WebUtils.getString(request, "action"));
    sc.setAttribute("filter", WebUtils.getString(request, "filter"));
    sc.setAttribute("persist", true);
    sc.setAttribute("types", types);
    sc.setAttribute("cfg", cfg);
    sc.getRequestDispatcher("/admin/config_edit.jsp").forward(request, response);
}

From source file:com.openkm.servlet.admin.StampServlet.java

/**
 * Edit image stamp//  w w  w .j a v  a  2  s  .co  m
 */
private void imageEdit(Session session, HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException, DatabaseException, NoSuchAlgorithmException {
    log.debug("imageEdit({}, {}, {})", new Object[] { session, request, response });
    ServletContext sc = getServletContext();
    int siId = WebUtils.getInt(request, "si_id");
    sc.setAttribute("action", WebUtils.getString(request, "action"));
    sc.setAttribute("persist", true);
    sc.setAttribute("users", AuthDAO.findAllUsers(true));
    sc.setAttribute("stamp", StampImageDAO.findByPk(siId));
    sc.getRequestDispatcher("/admin/stamp_image_edit.jsp").forward(request, response);
    log.debug("imageEdit: void");
}

From source file:com.openkm.servlet.admin.StampServlet.java

/**
 * Delete image stamp//  w  w w .j  a  va2  s  .c o  m
 */
private void imageDelete(Session session, HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException, DatabaseException, NoSuchAlgorithmException {
    log.debug("imageDelete({}, {}, {})", new Object[] { session, request, response });
    ServletContext sc = getServletContext();
    int siId = WebUtils.getInt(request, "si_id");
    sc.setAttribute("action", WebUtils.getString(request, "action"));
    sc.setAttribute("persist", true);
    sc.setAttribute("users", AuthDAO.findAllUsers(true));
    sc.setAttribute("stamp", StampImageDAO.findByPk(siId));
    sc.getRequestDispatcher("/admin/stamp_image_edit.jsp").forward(request, response);
    log.debug("imageDelete: void");
}

From source file:com.openkm.servlet.admin.DbRepositoryViewServlet.java

/**
 * Edit node property./*  ww  w .  jav  a2  s.  c om*/
 */
private void edit(String uuid, String path, HttpServletRequest request, HttpServletResponse response)
        throws PathNotFoundException, DatabaseException, ServletException, IOException {
    log.debug("edit({}, {})", new Object[] { request, response });
    String property = WebUtils.getString(request, "property");
    String group = WebUtils.getString(request, "group");
    String value = WebUtils.getString(request, "value");
    String field = WebUtils.getString(request, "field");

    ServletContext sc = getServletContext();
    sc.setAttribute("uuid", uuid);
    sc.setAttribute("path", path);
    sc.setAttribute("field", field);
    sc.setAttribute("property", property);
    sc.setAttribute("group", group);
    sc.setAttribute("value", value);
    sc.getRequestDispatcher("/admin/db_repository_edit.jsp").forward(request, response);
    log.debug("edit: void");
}

From source file:com.openkm.servlet.admin.StampServlet.java

/**
 * Delete text stamp//from   w  w w . j a  v a  2 s  .  c om
 */
private void textDelete(Session session, HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException, DatabaseException, NoSuchAlgorithmException {
    log.debug("textDelete({}, {}, {})", new Object[] { session, request, response });

    if (WebUtils.getBoolean(request, "persist")) {
        int stId = WebUtils.getInt(request, "st_id");
        StampTextDAO.delete(stId);

        // Activity log
        UserActivity.log(session.getUserID(), "ADMIN_STAMP_TEXT_DELETE", Integer.toString(stId), null);
    } else {
        ServletContext sc = getServletContext();
        int stId = WebUtils.getInt(request, "st_id");
        sc.setAttribute("action", WebUtils.getString(request, "action"));
        sc.setAttribute("persist", true);
        sc.setAttribute("users", AuthDAO.findAllUsers(true));
        sc.setAttribute("stamp", StampTextDAO.findByPk(stId));
        sc.getRequestDispatcher("/admin/stamp_text_edit.jsp").forward(request, response);
    }

    log.debug("textDelete: void");
}

From source file:com.openkm.servlet.admin.StampServlet.java

/**
 * Edit text stamp// w w  w  .  ja v a2  s. c o m
 */
private void textEdit(Session session, HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException, DatabaseException, NoSuchAlgorithmException {
    log.debug("textEdit({}, {}, {})", new Object[] { session, request, response });

    if (WebUtils.getBoolean(request, "persist")) {
        StampText st = new StampText();
        st.setId(WebUtils.getInt(request, "st_id"));
        st.setName(WebUtils.getString(request, "st_name"));
        st.setDescription(WebUtils.getString(request, "st_description"));
        st.setText(WebUtils.getString(request, "st_text"));
        st.setLayer(WebUtils.getInt(request, "st_layer"));
        st.setOpacity(WebUtils.getFloat(request, "st_opacity"));
        st.setSize(WebUtils.getInt(request, "st_size"));
        st.setColor(WebUtils.getString(request, "st_color"));
        st.setAlign(WebUtils.getInt(request, "st_align"));
        st.setRotation(WebUtils.getInt(request, "st_rotation"));
        st.setExprX(WebUtils.getString(request, "st_expr_x"));
        st.setExprY(WebUtils.getString(request, "st_expr_y"));
        st.setActive(WebUtils.getBoolean(request, "st_active"));
        st.setUsers(new HashSet<String>(WebUtils.getStringList(request, "st_users")));

        StampTextDAO.update(st);

        // Activity log
        UserActivity.log(session.getUserID(), "ADMIN_STAMP_TEXT_EDIT", Integer.toString(st.getId()),
                st.toString());
    } else {
        ServletContext sc = getServletContext();
        int stId = WebUtils.getInt(request, "st_id");
        sc.setAttribute("action", WebUtils.getString(request, "action"));
        sc.setAttribute("persist", true);
        sc.setAttribute("users", AuthDAO.findAllUsers(true));
        sc.setAttribute("stamp", StampTextDAO.findByPk(stId));
        sc.getRequestDispatcher("/admin/stamp_text_edit.jsp").forward(request, response);
    }

    log.debug("textEdit: void");
}

From source file:com.openkm.servlet.admin.BenchmarkServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    request.setCharacterEncoding("UTF-8");
    String action = request.getParameter("action") != null ? request.getParameter("action") : "";
    updateSessionManager(request);//from w w w .ja v a2 s  .  c o  m

    if (action.equals("okmImport")) {
        okmImport(request, response, BM_FOLDER + "_okm_import");
    } else if (action.equals("okmCopy")) {
        okmCopy(request, response);
    } else if (action.equals("okmApiHighGenerate")) {
        okmApiHighGenerate(request, response, BM_FOLDER + "_okm_api_high");
    } else if (action.equals("okmApiLowGenerate")) {
        okmApiLowGenerate(request, response, BM_FOLDER + "_okm_api_low");
    } else if (action.equals("okmRawGenerate")) {
        okmRawGenerate(request, response, BM_FOLDER + "_okm_raw");
    } else if (action.equals("jcrGenerate")) {
        jcrGenerate(request, response, BM_FOLDER + "_jcr");
    } else {
        ServletContext sc = getServletContext();
        sc.getRequestDispatcher("/admin/benchmark.jsp").forward(request, response);
    }
}

From source file:com.ikon.servlet.admin.ConfigServlet.java

/**
 * Edit config//from   w w  w . j  av  a2s .  c om
 */
private void edit(String userId, Map<String, String> types, HttpServletRequest request,
        HttpServletResponse response) throws ServletException, IOException, DatabaseException {
    ServletContext sc = getServletContext();
    String cfgKey = WebUtils.getString(request, "cfg_key");
    Config cfg = ConfigDAO.findByPk(cfgKey);
    sc.setAttribute("action", WebUtils.getString(request, "action"));
    sc.setAttribute("filter", WebUtils.getString(request, "filter"));
    sc.setAttribute("persist", true);
    sc.setAttribute("types", types);
    sc.setAttribute("cfg", cfg);
    sc.getRequestDispatcher("/admin/config_edit.jsp").forward(request, response);
}

From source file:com.ikon.servlet.admin.ConfigServlet.java

/**
 * Delete config/*from w  ww.ja  v  a 2  s .c o m*/
 */
private void delete(String userId, Map<String, String> types, HttpServletRequest request,
        HttpServletResponse response) throws ServletException, IOException, DatabaseException {
    ServletContext sc = getServletContext();
    String cfgKey = WebUtils.getString(request, "cfg_key");
    Config cfg = ConfigDAO.findByPk(cfgKey);
    sc.setAttribute("action", WebUtils.getString(request, "action"));
    sc.setAttribute("filter", WebUtils.getString(request, "filter"));
    sc.setAttribute("persist", true);
    sc.setAttribute("types", types);
    sc.setAttribute("cfg", cfg);
    sc.getRequestDispatcher("/admin/config_edit.jsp").forward(request, response);
}

From source file:com.ikon.servlet.admin.DatabaseQueryServlet.java

/**
 * Send error to be displayed inline/*from  ww w . ja  v  a 2  s.  com*/
 */
protected void sendError(ServletContext sc, HttpServletRequest request, HttpServletResponse response,
        Exception e) throws ServletException, IOException {
    sc.setAttribute("exception", e);
    sc.setAttribute("globalResults", null);
    sc.getRequestDispatcher("/admin/database_query.jsp").forward(request, response);
}