Example usage for javax.servlet.http HttpServletRequest setCharacterEncoding

List of usage examples for javax.servlet.http HttpServletRequest setCharacterEncoding

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest setCharacterEncoding.

Prototype

public void setCharacterEncoding(String env) throws UnsupportedEncodingException;

Source Link

Document

Overrides the name of the character encoding used in the body of this request.

Usage

From source file:fr.cph.stock.web.servlet.portfolio.ModifyEquityServlet.java

@Override
protected final void doGet(final HttpServletRequest request, final HttpServletResponse response)
        throws ServletException {
    try {/*w ww  .jav a 2 s.  c o m*/
        if (request.getCharacterEncoding() == null) {
            request.setCharacterEncoding("UTF-8");
        }
        String lang = CookieManagement.getCookieLanguage(Arrays.asList(request.getCookies()));
        LanguageFactory language = LanguageFactory.getInstance();
        HttpSession session = request.getSession();
        User user = (User) session.getAttribute("user");
        Double quantity = null, unitCostPrice = null, stopLoss = null, objective = null, yieldPersonal = null,
                parityPersonal = null;
        String namePersonal = null, sectorPersonal = null, industryPersonal = null, marketCapPersonal = null;
        try {
            if (request.getParameter("delete") != null) {
                if (request.getParameter("manual") != null) {
                    String id = request.getParameter("id");
                    String companyId = request.getParameter("companyId");
                    Equity e = new Equity();
                    e.setid(Integer.parseInt(id));
                    business.deleteEquity(e);
                    Company company = new Company();
                    company.setId(Integer.parseInt(companyId));
                    business.deleteCompany(company);
                    request.setAttribute("modified", language.getLanguage(lang).get("CONSTANT_DELETED") + " !");
                } else {
                    String id = request.getParameter("id");
                    Equity e = new Equity();
                    e.setid(Integer.parseInt(id));
                    business.deleteEquity(e);
                    request.setAttribute("modified", language.getLanguage(lang).get("CONSTANT_DELETED") + " !");
                }
            } else {
                String ticker = request.getParameter("ticker");
                String namePerso = request.getParameter("namePersonal");
                if (!namePerso.equals("")) {
                    namePersonal = namePerso;
                }
                String sectorPerso = request.getParameter("sectorPersonal");
                if (!sectorPerso.equals("")) {
                    sectorPersonal = sectorPerso;
                }
                String industryPerso = request.getParameter("industryPersonal");
                if (!industryPerso.equals("")) {
                    industryPersonal = industryPerso;
                }
                String marketCapPerso = request.getParameter("marketCapPersonal");
                if (!marketCapPerso.equals("")) {
                    marketCapPersonal = marketCapPerso;
                }
                String quant = request.getParameter("quantity");
                if (!quant.equals("")) {
                    quantity = NumberUtils.createDouble(quant);
                } else {
                    quantity = 0.0;
                }
                String unitCostP = request.getParameter("unitCostPrice");
                if (!unitCostP.equals("")) {
                    unitCostPrice = NumberUtils.createDouble(unitCostP);
                } else {
                    unitCostPrice = 0.0;
                }
                String stopLo = request.getParameter("stopLoss");
                if (!stopLo.equals("")) {
                    stopLoss = NumberUtils.createDouble(stopLo);
                }
                String objc = request.getParameter("objective");
                if (!objc.equals("")) {
                    objective = NumberUtils.createDouble(objc);
                }
                String yieldPerso = request.getParameter("yieldPersonal");
                if (!yieldPerso.equals("")) {
                    yieldPersonal = NumberUtils.createDouble(yieldPerso);
                }
                String parityPerso = request.getParameter("modifyParityPersonal");
                if (!parityPerso.equals("")) {
                    parityPersonal = NumberUtils.createDouble(parityPerso);
                }
                if (quantity == 0) {
                    request.setAttribute("modifyError", "Error: quantity can not be 0");
                } else {
                    Equity equity = new Equity();
                    equity.setNamePersonal(namePersonal);
                    equity.setSectorPersonal(sectorPersonal);
                    equity.setIndustryPersonal(industryPersonal);
                    equity.setMarketCapPersonal(marketCapPersonal);
                    equity.setQuantity(quantity);
                    equity.setUnitCostPrice(unitCostPrice);
                    equity.setStopLossLocal(stopLoss);
                    equity.setObjectivLocal(objective);
                    equity.setYieldPersonal(yieldPersonal);
                    equity.setParityPersonal(parityPersonal);
                    business.updateEquity(user.getId(), ticker, equity);
                    request.setAttribute("modified",
                            language.getLanguage(lang).get("CONSTANT_MODIFIED") + " !");
                }
                if (request.getParameter("manual") != null) {
                    String companyId = request.getParameter("companyId");
                    String quote = request.getParameter("quote");
                    Double quoteRes = null;
                    Integer companyIdRes = null;
                    if (quote != null && !quote.equals("") && companyId != null && !companyId.equals("")) {
                        quoteRes = Double.parseDouble(quote);
                        companyIdRes = Integer.parseInt(companyId);
                        business.updateCompanyManual(companyIdRes, quoteRes);
                    }
                }
            }
        } catch (YahooException e) {
            LOG.warn(e.getMessage(), e);
            request.setAttribute("modifyError", "Error: " + e.getMessage());
        } catch (NumberFormatException e) {
            LOG.warn(e.getMessage(), e);
            request.setAttribute("modifyError", "Error: " + e.getMessage());
        }
        request.getRequestDispatcher("home").forward(request, response);
    } catch (Throwable t) {
        LOG.error(t.getMessage(), t);
        throw new ServletException("Error: " + t.getMessage(), t);
    }
}

From source file:com.javaweb.controller.ThemTinTucServlet.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
 *
 * @param request servlet request/*from w ww .  j av a2s.  c om*/
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException, ParseException {
    response.setContentType("text/html;charset=UTF-8");
    request.setCharacterEncoding("UTF-8");

    //response.setCharacterEncoding("UTF-8");
    HttpSession session = request.getSession();
    //        session.removeAttribute("errorreg");
    String TieuDe = "", NoiDung = "", ngaydang = "", GhiChu = "", fileName = "";
    int idloaitin = 0, idTK = 0;

    TintucService tintucservice = new TintucService();

    //File upload
    String folderupload = getServletContext().getInitParameter("file-upload");
    String rootPath = getServletContext().getRealPath("/");
    filePath = rootPath + folderupload;
    isMultipart = ServletFileUpload.isMultipartContent(request);
    response.setContentType("text/html");
    java.io.PrintWriter out = response.getWriter();

    DiskFileItemFactory factory = new DiskFileItemFactory();
    // maximum size that will be stored in memory
    factory.setSizeThreshold(maxMemSize);
    // Location to save data that is larger than maxMemSize.
    factory.setRepository(new File("C:\\Windows\\Temp\\"));

    // Create a new file upload handler
    ServletFileUpload upload = new ServletFileUpload(factory);
    // maximum file size to be uploaded.
    upload.setSizeMax(maxFileSize);

    try {
        // Parse the request to get file items.
        List fileItems = upload.parseRequest(request);

        // Process the uploaded file items
        Iterator i = fileItems.iterator();

        while (i.hasNext()) {
            FileItem fi = (FileItem) i.next();
            if (!fi.isFormField()) {
                // Get the uploaded file parameters

                String fieldName = fi.getFieldName();
                fileName = fi.getName();
                String contentType = fi.getContentType();
                boolean isInMemory = fi.isInMemory();
                long sizeInBytes = fi.getSize();

                //change file name
                fileName = FileService.ChangeFileName(fileName);

                // Write the file
                if (fileName.lastIndexOf("\\") >= 0) {
                    file = new File(filePath + fileName.substring(fileName.lastIndexOf("\\")));
                } else {
                    file = new File(filePath + "/" + fileName.substring(fileName.lastIndexOf("\\") + 1));
                }
                fi.write(file);
                //                    out.println("Uploaded Filename: " + fileName + "<br>");
            }

            if (fi.isFormField()) {
                if (fi.getFieldName().equalsIgnoreCase("TieuDe")) {
                    TieuDe = fi.getString("UTF-8");
                } else if (fi.getFieldName().equalsIgnoreCase("NoiDung")) {
                    NoiDung = fi.getString("UTF-8");
                } else if (fi.getFieldName().equalsIgnoreCase("NgayDang")) {
                    ngaydang = fi.getString("UTF-8");
                } else if (fi.getFieldName().equalsIgnoreCase("GhiChu")) {
                    GhiChu = fi.getString("UTF-8");
                } else if (fi.getFieldName().equalsIgnoreCase("loaitin")) {
                    idloaitin = Integer.parseInt(fi.getString("UTF-8"));
                } else if (fi.getFieldName().equalsIgnoreCase("idtaikhoan")) {
                    idTK = Integer.parseInt(fi.getString("UTF-8"));
                }
            }
        }

    } catch (Exception ex) {
        System.out.println(ex);
    }

    Date NgayDang = new SimpleDateFormat("yyyy-MM-dd").parse(ngaydang);
    Tintuc tintuc = new Tintuc(idloaitin, idTK, fileName, TieuDe, NoiDung, NgayDang, GhiChu);

    boolean rs = tintucservice.InsertTintuc(tintuc);
    if (rs) {
        session.setAttribute("kiemtra", "1");
        String url = "ThemTinTuc.jsp";
        response.sendRedirect(url);
    } else {
        session.setAttribute("kiemtra", "0");
        String url = "ThemTinTuc.jsp";
        response.sendRedirect(url);
    }

    //        try (PrintWriter out = response.getWriter()) {
    //            /* TODO output your page here. You may use following sample code. */
    //            out.println("<!DOCTYPE html>");
    //            out.println("<html>");
    //            out.println("<head>");
    //            out.println("<title>Servlet ThemTinTucServlet</title>");            
    //            out.println("</head>");
    //            out.println("<body>");
    //            out.println("<h1>Servlet ThemTinTucServlet at " + request.getContextPath() + "</h1>");
    //            out.println("</body>");
    //            out.println("</html>");
    //        }
}

From source file:Controlador.Contr_Satisfaccion.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.// ww  w  .j av  a 2  s . c om
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    request.setCharacterEncoding("UTF-8");
    response.setContentType("text/html;charset=UTF-8");
    //declaramos las variables necesarias para todo el proyecto
    String Mensaje, Comentario, Rating, CodigoEvento, CodigoUsuario;
    HttpSession session = request.getSession(true);
    Cls_Satisfaccion sat = new Cls_Satisfaccion();

    //evaluamos las peticiones realizadas
    if (request.getParameter("RegistrarSatisfaccion") != null) {
        //incializamos las varaibles para codigo de evento y usuario
        CodigoEvento = request.getParameter("CodigoEvento");
        CodigoUsuario = (String) session.getAttribute("Codigo");

        //evaluamos el contendio de rating
        if ((request.getParameter("Rating") != null && !request.getParameter("Rating").equals("0"))
                && (request.getParameter("comentario") != null
                        && !request.getParameter("comentario").equals(""))) {
            //gudardamos el contenido de rating y comentario
            Rating = request.getParameter("Rating");
            Comentario = request.getParameter("comentario");

            //realizamos los metodos necesarios para registar la calificacion
            if (sat.setRegistrarCalificacionYComentarioSatisfaccion(CodigoUsuario, CodigoEvento, Rating,
                    Comentario)) {
                //guardamos el mensaje correspondiente
                session.setAttribute("Mensaje", "La crtica ha sido registrada correctamente.");
                session.setAttribute("TipoMensaje", "Dio");
            } else {
                //guardamos el mensaje correspondiente
                session.setAttribute("Mensaje", sat.getMensaje());
                session.setAttribute("TipoMensaje", "NODio");
            }
            //retornamos a la vista
            response.sendRedirect("View/DetalleEvento.jsp?CodigoEvento=" + CodigoEvento);

        } else if (request.getParameter("Rating") != null && !request.getParameter("Rating").equals("0")) {
            //gudardamos el contenido de rating 
            Rating = request.getParameter("Rating");

            //realizamos los metodos necesarios para registar la calificacion
            if (sat.setRegistrarCalificacionSatisfaccion(CodigoUsuario, CodigoEvento, Rating)) {
                //guardamos el mensaje correspondiente
                session.setAttribute("Mensaje", "La crtica ha sido registrada correctamente.");
                session.setAttribute("TipoMensaje", "Dio");
            } else {
                //guardamos el mensaje correspondiente
                session.setAttribute("Mensaje", sat.getMensaje());
                session.setAttribute("TipoMensaje", "NODio");
            }
            //retornamos a la vista
            response.sendRedirect("View/DetalleEvento.jsp?CodigoEvento=" + CodigoEvento);

        } else if (request.getParameter("comentario") != null
                && !request.getParameter("comentario").equals("")) {

            Comentario = request.getParameter("comentario");
            //realizamos los metodos necesarios para registar la calificacion
            if (sat.setRegistrarComentarioSatisfaccion(CodigoUsuario, CodigoEvento, Comentario)) {
                //guardamos el mensaje correspondiente
                session.setAttribute("Mensaje", "La crtica ha sido registrada correctamente.");
                session.setAttribute("TipoMensaje", "Dio");
            } else {
                //guardamos el mensaje correspondiente
                session.setAttribute("Mensaje", sat.getMensaje());
                session.setAttribute("TipoMensaje", "NODio");
            }
            //retornamos a la vista
            response.sendRedirect("View/DetalleEvento.jsp?CodigoEvento=" + CodigoEvento);
        } else {
            //guardamos el mensaje correspondiente
            session.setAttribute("Mensaje", "Debe seleccionar una puntuacin o escribir un comentario.");
            session.setAttribute("TipoMensaje", "NODio");
            response.sendRedirect("View/DetalleEvento.jsp?CodigoEvento=" + CodigoEvento);
        }

    } else if (request.getParameter("accion").equals("comentarios_aleatorios")) {
        String Datos[][] = sat.BuscarComentariosAleatorios();
        JSONObject obj = new JSONObject();
        int i = 0;
        for (String row[] : Datos) {
            JSONObject ob = new JSONObject();

            ob.put("usuario", row[0]);
            ob.put("evento", row[1]);
            ob.put("comentario", row[2]);
            obj.put(i, ob);
            i++;
        }
        /*Se imprime el resultado*/
        PrintWriter out = response.getWriter();
        out.print(obj);
        out.close();
    } else if (request.getParameter("accion").equals("calificacion_evento")) {
        CodigoEvento = request.getParameter("id_evento");
        int[] Datos = sat.getCalificacionEvento(CodigoEvento);
        JSONObject obj = new JSONObject();
        JSONObject ob = new JSONObject();

        ob.put("uno", Datos[0]);
        ob.put("dos", Datos[1]);
        ob.put("tres", Datos[2]);
        ob.put("cuatro", Datos[3]);
        ob.put("cinco", Datos[4]);

        obj.put(1, ob);

        PrintWriter out = response.getWriter();
        out.print(obj);
        out.close();
    } else if (request.getParameter("accion").equals("registrar_calificacion_evento_android")) {
        String codigoevento = request.getParameter("codigoevento");
        String codigousuario = request.getParameter("codigousuario");
        String comentario = request.getParameter("comentario");
        String calificacion = request.getParameter("calificacion");
        String fecha = request.getParameter("fecha");

        sat.registrarSatisfaccionAndroid(codigoevento, codigousuario, fecha, comentario, calificacion);
        String dato = sat.getMensaje();
        PrintWriter out = response.getWriter();
        out.print(dato);
        out.close();
    } else if (request.getParameter("accion").equals("consulta_calificar_evento_android")) {
        String codigoevento = request.getParameter("codigoevento");
        String codigousuario = request.getParameter("codigousuario");
        PrintWriter out = response.getWriter();
        String[] Datos = sat.consultacalificarevento(codigoevento, codigousuario);
        if (Datos == null) {
            out.print("Comente");
        } else {
            JSONObject ob = new JSONObject();
            ob.put("Comentario", Datos[0]);
            ob.put("Calificacion", Datos[1]);
            out.print(ob);
        }
        out.close();

    } else if (request.getParameter("accion").equals("consultar_comentarios_evento_android")) {
        String codigoevento = request.getParameter("codigoevento");
        JSONObject obj = new JSONObject();
        JSONObject ob = new JSONObject();
        JSONArray list = new JSONArray();
        PrintWriter out = response.getWriter();

        String[][] Datos = sat.consultacomentarioseventoAndroid(codigoevento);

        for (String[] row : Datos) {
            ob.put("Nombre", row[0]);
            ob.put("Comentario", row[1]);
            ob.put("Fecha", row[2]);
            list.add(ob);
        }
        obj.put("comentarios", list);
        out.print(obj);
        out.close();

    } else {
        /*Se redirecciona si no se realizo ninguna peticion*/
        response.sendRedirect("View/ConsultaEvento.jsp");
    }
}

From source file:org.jbpm.formModeler.service.bb.mvc.controller.ControllerServlet.java

/**
 * Process incoming HTTP requests/*from  www. j ava2  s.  co m*/
 *
 * @param request  Object that encapsulates the request to the servlet.
 * @param response Object that encapsulates the response from the servlet.
 */
public final void service(final HttpServletRequest request, final HttpServletResponse response)
        throws ServletException, IOException {
    if (theApp == null)
        initApp();
    if (initSuccess) {
        try {
            HTTPSettings settings = HTTPSettings.lookup();
            request.setCharacterEncoding(settings.getEncoding());
        } catch (UnsupportedEncodingException e) {
            log.error("Error: ", e);
        }

        // Init the request context.
        ControllerServletHelper helper = ControllerServletHelper.lookup();
        synchronized (helper) {
            CommandRequest cmdRq = helper.initThreadLocal(request, response);
            ControllerStatus.lookup().setRequest(cmdRq);
            try {
                // Process the request (control layer)
                processTheRequest(cmdRq);

                // Render the view (presentation layer)
                processTheView(cmdRq);
            } finally {

                // Clear the request context.
                helper.clearThreadLocal(request, response);
            }
        }
    } else {
        log.error("Received request, but application servlet hasn't been properly initialized. Ignoring.");
        response.sendError(500, "Application incorrectly initialized.");
    }
}

From source file:org.ecside.filter.ECSideFilter.java

 public void doAjaxFilter(HttpServletRequest request,
      HttpServletResponse response, FilterChain chain)
      throws IOException, ServletException {

   request.setCharacterEncoding("UTF-8");
      //from w  w  w .  j  a  v  a2s  .  c o m
   String findAjaxZoneAtClient = request
         .getParameter(TableConstants.AJAX_FINDZONE_CLIENT);
   if (findAjaxZoneAtClient != null
         && ("false".equalsIgnoreCase(findAjaxZoneAtClient) || "0"
               .equals(findAjaxZoneAtClient))) {
      ECSideAjaxResponseWrapper bufferResponseWrapper = new ECSideAjaxResponseWrapper(
            response);
      try {

         String ectableId = request
               .getParameter(TableConstants.EXTREME_COMPONENTS_INSTANCE);
            
         chain.doFilter(request, bufferResponseWrapper);
         String zone = bufferResponseWrapper.findSubstring(ECSideUtils
               .getAjaxBegin(ectableId), ECSideUtils
               .getAjaxEnd(ectableId));
         HttpServletResponse originalResponse = bufferResponseWrapper
               .getOriginalResponse();
         if (zone != null) {
            originalResponse.getOutputStream().write(
                  zone.getBytes("UTF-8"));
         }
         // originalResponse.flushBuffer();
         originalResponse.getOutputStream().flush();
         originalResponse.getOutputStream().close();
      } catch (Exception e) {
         LogHandler.errorLog(logger, e);
         response.setContentType("text/html;charset=UTF-8");
         response.getWriter().println(
               "Exception:<br />\n"
                     + ExceptionUtils.formatStackTrace(e)
                           .replaceAll("\n", "<br/>\n"));
         response.getWriter().close();

      }
   } else {
      chain.doFilter(request, response);
   }
}

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

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    log.debug("doGet({}, {})", request, response);
    request.setCharacterEncoding("UTF-8");
    String action = WebUtils.getString(request, "action");
    String userId = request.getRemoteUser();
    updateSessionManager(request);/* w  w  w . j a v  a  2s  . c om*/

    try {
        if (action.equals("create")) {
            create(userId, request, response);
        } else if (action.equals("edit")) {
            edit(userId, request, response);
        } else if (action.equals("delete")) {
            delete(userId, request, response);
        } else if (action.equals("export")) {
            export(userId, request, response);
        } else {
            list(userId, request, response);
        }
    } catch (DatabaseException e) {
        log.error(e.getMessage(), e);
        sendErrorRedirect(request, response, e);
    }
}

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

@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    log.debug("doGet({}, {})", request, response);
    request.setCharacterEncoding("UTF-8");
    String action = WebUtils.getString(request, "action");
    Session session = null;/*from w w w  . j ava 2 s.c  o m*/
    updateSessionManager(request);

    try {
        if (!action.equals(null)) {
            writeToPropertyGroupsXML(request, response);
            register(session, request, response);
        }

        list(request, response);
    } catch (RepositoryException e) {
        log.error(e.getMessage(), e);
        sendErrorRedirect(request, response, e);
    } catch (ParseException e) {
        log.error(e.getMessage(), e);
        sendErrorRedirect(request, response, e);
    } catch (DatabaseException e) {
        log.error(e.getMessage(), e);
        sendErrorRedirect(request, response, e);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:it.polimi.modaclouds.cloudapp.mic.servlet.RegisterServlet.java

private void parseReq(HttpServletRequest req, HttpServletResponse response)
        throws ServletException, IOException {

    try {/*from   www.j a v a  2s  . co  m*/

        MF mf = MF.getFactory();

        req.setCharacterEncoding("UTF-8");

        ServletFileUpload upload = new ServletFileUpload();

        FileItemIterator iterator = upload.getItemIterator(req);

        HashMap<String, String> map = new HashMap<String, String>();

        while (iterator.hasNext()) {

            FileItemStream item = iterator.next();

            InputStream stream = item.openStream();

            if (item.isFormField()) {

                String field = item.getFieldName();

                String value = Streams.asString(stream);

                map.put(field, value);

                stream.close();

            } else {

                String filename = item.getName();

                String[] extension = filename.split("\\.");

                String mail = map.get("mail");

                if (mail != null) {

                    filename = mail + "_" + String.valueOf(filename.hashCode()) + "."
                            + extension[extension.length - 1];

                } else {

                    filename = String.valueOf(filename.hashCode()) + "." + extension[extension.length - 1];

                }

                map.put("filename", filename);

                byte[] buffer = IOUtils.toByteArray(stream);

                mf.getBlobManagerFactory().createCloudBlobManager().uploadBlob(buffer,

                        filename);

                stream.close();

            }

        }

        String email = map.get("mail");

        String firstName = map.get("firstName");

        String lastName = map.get("lastName");

        String dayS = map.get("day");

        String monthS = map.get("month");

        String yearS = map.get("year");

        String password = map.get("password");

        String filename = map.get("filename");

        String date = yearS + "-" + monthS + "-" + dayS;

        char gender = map.get("gender").charAt(0);

        RequestDispatcher disp;

        Connection c = mf.getSQLService().getConnection();

        String stm = "INSERT INTO UserProfile VALUES('" + email + "', '" + password + "', '" + firstName
                + "', '" + lastName + "', '" + date + "', '" + gender + "', '" + filename + "')";

        Statement statement = c.createStatement();

        statement.executeUpdate(stm);

        statement.close();

        c.close();

        req.getSession(true).setAttribute("actualUser", email);

        req.getSession(true).setAttribute("edit", "false");

        disp = req.getRequestDispatcher("SelectTopic.jsp");

        disp.forward(req, response);

    } catch (UnsupportedEncodingException e) {

        e.printStackTrace();

    } catch (SQLException e) {

        e.printStackTrace();

    } catch (FileUploadException e) {

        e.printStackTrace();

    }

}

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

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    log.debug("doGet({}, {})", request, response);
    request.setCharacterEncoding("UTF-8");
    String action = WebUtils.getString(request, "action");
    String userId = request.getRemoteUser();
    updateSessionManager(request);/*  ww  w .  j  a  v  a  2s .c  om*/

    try {
        if (action.equals("create")) {
            ServletContext sc = getServletContext();
            Report rp = new Report();
            sc.setAttribute("action", action);
            sc.setAttribute("types", types);
            sc.setAttribute("rp", rp);
            sc.getRequestDispatcher("/admin/report_edit.jsp").forward(request, response);
        } else if (action.equals("edit")) {
            ServletContext sc = getServletContext();
            int rpId = WebUtils.getInt(request, "rp_id");
            Report rp = ReportDAO.findByPk(rpId);
            sc.setAttribute("action", action);
            sc.setAttribute("types", types);
            sc.setAttribute("rp", rp);
            sc.getRequestDispatcher("/admin/report_edit.jsp").forward(request, response);
        } else if (action.equals("delete")) {
            ServletContext sc = getServletContext();
            int rpId = WebUtils.getInt(request, "rp_id");
            Report rp = ReportDAO.findByPk(rpId);
            sc.setAttribute("action", action);
            sc.setAttribute("types", types);
            sc.setAttribute("rp", rp);
            sc.getRequestDispatcher("/admin/report_edit.jsp").forward(request, response);
        } else if (action.equals("paramList")) {
            paramList(userId, request, response);
        } else if (action.equals("getParams")) {
            getParams(userId, request, response);
        } else if (action.equals("execute")) {
            execute(userId, request, response);
        } else {
            list(userId, request, response);
        }
    } catch (DatabaseException e) {
        log.error(e.getMessage(), e);
        sendErrorRedirect(request, response, e);
    } catch (JRException e) {
        log.error(e.getMessage(), e);
        sendErrorRedirect(request, response, e);
    } catch (EvalError e) {
        log.error(e.getMessage(), e);
        sendErrorRedirect(request, response, e);
    } catch (ParseException e) {
        log.error(e.getMessage(), e);
        sendErrorRedirect(request, response, e);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        sendErrorRedirect(request, response, e);
    }
}

From source file:com.bluexml.side.Framework.alfresco.languagepicker.MyWebScriptServlet.java

protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    if (logger.isDebugEnabled())
        logger.debug("Processing request (" + req.getMethod() + ") " + req.getRequestURL()
                + (req.getQueryString() != null ? "?" + req.getQueryString() : ""));

    if (req.getCharacterEncoding() == null) {
        req.setCharacterEncoding("UTF-8");
    }/*from w  w w  . ja va  2  s .  c o  m*/

    setUserLanguage(req);

    try {
        WebScriptServletRuntime runtime = new WebScriptServletRuntime(container, authenticatorFactory, req, res,
                serverProperties);
        runtime.executeScript();
    } finally {
        // clear threadlocal
        I18NUtil.setLocale(null);
    }
}