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:com.megaeyes.web.controller.UserController.java

@ControllerDescription(description = "?ID??", isLog = false, isCheckSession = true)
@RequestMapping("/getAllChildUsersByOrganId.json")
public void getAllChildUsersByOrganId(HttpServletRequest request, HttpServletResponse response)
        throws UnsupportedEncodingException {
    request.setCharacterEncoding("UTF-8");
    ListUserResponse resp = new ListUserResponse();
    String organId = (String) request.getAttribute("organId");
    try {/*from   w  w  w. java2 s  .  c o m*/
        List<TUser> list = userManager.getAllChildUsersByOrganId(organId);
        resp.setUser(list);
        resp.setCode(ErrorCode.SUCCESS);
    } catch (BusinessException be) {
        resp.setCode(be.getCode());
        resp.setMessage(be.getMessage());
    }
    writePageNoZip(response, resp);
}

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

@Override
@SuppressWarnings("unchecked")
public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    log.debug("doPost({}, {})", request, response);
    request.setCharacterEncoding("UTF-8");
    ServletContext sc = getServletContext();
    String action = null;/*from   ww  w. j  av  a2s.  c  o m*/
    String filter = null;
    String userId = request.getRemoteUser();
    Session dbSession = null;
    updateSessionManager(request);

    try {
        if (ServletFileUpload.isMultipartContent(request)) {
            InputStream is = null;
            FileItemFactory factory = new DiskFileItemFactory();
            ServletFileUpload upload = new ServletFileUpload(factory);
            List<FileItem> items = upload.parseRequest(request);
            Config cfg = new Config();
            byte data[] = null;

            for (Iterator<FileItem> it = items.iterator(); it.hasNext();) {
                FileItem item = it.next();

                if (item.isFormField()) {
                    if (item.getFieldName().equals("action")) {
                        action = item.getString("UTF-8");
                    } else if (item.getFieldName().equals("filter")) {
                        filter = item.getString("UTF-8");
                    } else if (item.getFieldName().equals("cfg_key")) {
                        cfg.setKey(item.getString("UTF-8"));
                    } else if (item.getFieldName().equals("cfg_type")) {
                        cfg.setType(item.getString("UTF-8"));
                    } else if (item.getFieldName().equals("cfg_value")) {
                        cfg.setValue(item.getString("UTF-8").trim());
                    }
                } else {
                    is = item.getInputStream();
                    data = IOUtils.toByteArray(is);
                    is.close();
                }
            }

            if (action.equals("create")) {
                if (Config.BOOLEAN.equals(cfg.getType())) {
                    cfg.setValue(Boolean.toString(cfg.getValue() != null && !cfg.getValue().equals("")));
                } else if (Config.SELECT.equals(cfg.getType())) {
                    ConfigStoredSelect stSelect = ConfigDAO.getSelect(cfg.getKey());

                    if (stSelect != null) {
                        for (ConfigStoredOption stOption : stSelect.getOptions()) {
                            if (stOption.getValue().equals(cfg.getValue())) {
                                stOption.setSelected(true);
                            }
                        }
                    }

                    cfg.setValue(new Gson().toJson(stSelect));
                }

                ConfigDAO.create(cfg);
                com.ikon.core.Config.reload(sc, new Properties());

                // Activity log
                UserActivity.log(userId, "ADMIN_CONFIG_CREATE", cfg.getKey(), null, cfg.toString());
                list(userId, filter, request, response);
            } else if (action.equals("edit")) {
                if (Config.BOOLEAN.equals(cfg.getType())) {
                    cfg.setValue(Boolean.toString(cfg.getValue() != null && !cfg.getValue().equals("")));
                } else if (Config.SELECT.equals(cfg.getType())) {
                    ConfigStoredSelect stSelect = ConfigDAO.getSelect(cfg.getKey());

                    if (stSelect != null) {
                        for (ConfigStoredOption stOption : stSelect.getOptions()) {
                            if (stOption.getValue().equals(cfg.getValue())) {
                                stOption.setSelected(true);
                            } else {
                                stOption.setSelected(false);
                            }
                        }
                    }

                    cfg.setValue(new Gson().toJson(stSelect));
                }

                ConfigDAO.update(cfg);
                com.ikon.core.Config.reload(sc, new Properties());

                // Activity log
                UserActivity.log(userId, "ADMIN_CONFIG_EDIT", cfg.getKey(), null, cfg.toString());
                list(userId, filter, request, response);
            } else if (action.equals("delete")) {
                ConfigDAO.delete(cfg.getKey());
                com.ikon.core.Config.reload(sc, new Properties());

                // Activity log
                UserActivity.log(userId, "ADMIN_CONFIG_DELETE", cfg.getKey(), null, null);
                list(userId, filter, request, response);
            } else if (action.equals("import")) {
                dbSession = HibernateUtil.getSessionFactory().openSession();
                importConfig(userId, request, response, data, dbSession);

                // Activity log
                UserActivity.log(request.getRemoteUser(), "ADMIN_CONFIG_IMPORT", null, null, null);
                list(userId, filter, request, response);
            }
        }
    } catch (DatabaseException e) {
        log.error(e.getMessage(), e);
        sendErrorRedirect(request, response, e);
    } catch (FileUploadException e) {
        log.error(e.getMessage(), e);
        sendErrorRedirect(request, response, e);
    } catch (SQLException e) {
        log.error(e.getMessage(), e);
        sendErrorRedirect(request, response, e);
    } finally {
        HibernateUtil.close(dbSession);
    }
}

From source file:com.aaasec.sigserv.csspserver.SpServlet.java

/**
 * Processes requests for both HTTP// w ww.ja v a2  s .com
 * <code>GET</code> and
 * <code>POST</code> methods.
 *
 * @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.setCharacterEncoding("UTF-8");
    response.setContentType("text/html;charset=UTF-8");
    response.setHeader("Cache-Control", "no-cache");

    SpSession session = getSession(request, response);

    RequestModel req = reqFactory.getRequestModel(request, session);
    AuthData authdata = req.getAuthData();

    // Supporting devmode login
    if (SpModel.isDevmode()) {
        authdata = TestIdentities.getTestID(request, req);
        req.setAuthData(authdata);
        if (authdata.getAuthType().length() == 0) {
            authdata.setAuthType("devlogin");
        }
        session.setIdpEntityId(authdata.getIdpEntityID());
        session.setSignerAttribute(RequestModelFactory.getAttrOidString(authdata.getIdAttribute()));
        session.setSignerId(authdata.getId());
    }

    //Terminate if no valid request data
    if (req == null) {
        response.setStatus(HttpServletResponse.SC_NO_CONTENT);
        response.getWriter().write("");
        return;
    }

    // Handle form post from web page
    boolean isMultipart = ServletFileUpload.isMultipartContent(request);
    if (isMultipart) {
        response.getWriter().write(SpServerLogic.processFileUpload(request, response, req));
        return;
    }

    // Handle auth data request 
    if (req.getAction().equals("authdata")) {
        response.setContentType("application/json");
        response.setHeader("Cache-Control", "no-cache");
        response.getWriter().write(gson.toJson(authdata));
        return;
    }

    // Get list of serverstored xml documents
    if (req.getAction().equals("doclist")) {
        response.setContentType("application/json");
        response.getWriter().write(SpServerLogic.getDocList());
        return;
    }

    // Provide info about the session for logout handling
    if (req.getAction().equals("logout")) {
        response.setContentType("application/json");
        Logout lo = new Logout();
        lo.authType = (request.getAuthType() == null) ? "" : request.getAuthType();
        lo.devmode = String.valueOf(SpModel.isDevmode());
        response.getWriter().write(gson.toJson(lo));
        return;
    }

    // Respons to a client alive check to test if the server session is alive
    if (req.getAction().equals("alive")) {
        response.setContentType("application/json");
        response.getWriter().write("[]");
        return;
    }

    // Handle sign request and return Xhtml form with post data to the signature server
    if (req.getAction().equals("sign")) {
        boolean addSignMessage = (req.getParameter().equals("message"));
        String xhtml = SpServerLogic.prepareSignRedirect(req, addSignMessage);
        response.getWriter().write(xhtml);
        return;
    }

    // Get status data about the current session
    if (req.getAction().equals("status")) {
        response.setContentType("application/json");
        response.getWriter().write(gson.toJson(session.getStatus()));
        return;
    }

    // Handle a declined sign request
    if (req.getAction().equals("declined")) {
        if (SpModel.isDevmode()) {
            response.sendRedirect("index.jsp?declined=true");
            return;
        }
        response.sendRedirect("https://eid2cssp.3xasecurity.com/sign/index.jsp?declined=true");
        return;
    }

    // Return Request and response data as a file.
    if (req.getAction().equalsIgnoreCase("getReqRes")) {
        response.setContentType("text/xml;charset=UTF-8");
        byte[] data = TestCases.getRawData(req);
        BufferedInputStream fis = new BufferedInputStream(new ByteArrayInputStream(data));
        ServletOutputStream output = response.getOutputStream();
        if (req.getParameter().equalsIgnoreCase("download")) {
            response.setHeader("Content-Disposition", "attachment; filename=" + req.getId() + ".xml");
        }

        int readBytes = 0;
        byte[] buffer = new byte[10000];
        while ((readBytes = fis.read(buffer, 0, 10000)) != -1) {
            output.write(buffer, 0, readBytes);
        }
        output.flush();
        output.close();
        fis.close();
        return;
    }

    // Return the signed document
    if (req.getAction().equalsIgnoreCase("getSignedDoc")
            || req.getAction().equalsIgnoreCase("getUnsignedDoc")) {
        // If the request if for a plaintext document, or only if the document has a valid signature
        if (session.getStatus().signedDocValid || req.getAction().equalsIgnoreCase("getUnsignedDoc")) {
            response.setContentType(session.getDocumentType().getMimeType());
            switch (session.getDocumentType()) {
            case XML:
                response.getWriter().write(new String(session.getSignedDoc(), Charset.forName("UTF-8")));
                return;
            case PDF:
                File docFile = session.getDocumentFile();
                if (req.getAction().equalsIgnoreCase("getSignedDoc") && session.getStatus().signedDocValid) {
                    docFile = session.getSigFile();
                }
                FileInputStream fis = new FileInputStream(docFile);
                ServletOutputStream output = response.getOutputStream();
                if (req.getParameter().equalsIgnoreCase("download")) {
                    response.setHeader("Content-Disposition", "attachment; filename=" + "signedPdf.pdf");
                }

                int readBytes = 0;
                byte[] buffer = new byte[10000];
                while ((readBytes = fis.read(buffer, 0, 10000)) != -1) {
                    output.write(buffer, 0, readBytes);
                }
                output.flush();
                output.close();
                fis.close();
                return;
            }
            return;
        } else {
            if (SpModel.isDevmode()) {
                response.sendRedirect("index.jsp");
                return;
            }
            response.sendRedirect("https://eid2cssp.3xasecurity.com/sign/index.jsp");
            return;
        }
    }

    // Process a sign response from the signature server
    if (req.getSigResponse().length() > 0) {
        try {
            byte[] sigResponse = Base64Coder.decode(req.getSigResponse().trim());

            // Handle response
            SpServerLogic.completeSignedDoc(sigResponse, req);

        } catch (Exception ex) {
        }
        if (SpModel.isDevmode()) {
            response.sendRedirect("index.jsp");
            return;
        }
        response.sendRedirect("https://eid2cssp.3xasecurity.com/sign/index.jsp");
        return;
    }

    // Handle testcases
    if (req.getAction().equals("test")) {
        boolean addSignMessage = (req.getParameter().equals("message"));
        String xhtml = TestCases.prepareTestRedirect(request, response, req, addSignMessage);
        respond(response, xhtml);
        return;
    }

    // Get test data for display such as request data, response data, certificates etc.
    if (req.getAction().equals("info")) {
        switch (session.getDocumentType()) {
        case PDF:
            File returnFile = null;
            if (req.getId().equalsIgnoreCase("document")) {
                respond(response, getDocIframe("getUnsignedDoc", needPdfDownloadButton(request)));
            }
            if (req.getId().equalsIgnoreCase("formSigDoc")) {
                respond(response, getDocIframe("getSignedDoc", needPdfDownloadButton(request)));
            }
            respond(response, TestCases.getTestData(req));
            return;
        default:
            respond(response, TestCases.getTestData(req));
            return;
        }
    }

    if (req.getAction().equals("verify")) {
        response.setContentType("text/xml;charset=UTF-8");
        String sigVerifyReport = TestCases.getTestData(req);
        if (sigVerifyReport != null) {
            respond(response, sigVerifyReport);
            return;
        }
    }

    nullResponse(response);
}

From source file:com.megaeyes.web.controller.UserController.java

@ControllerDescription(description = "", isLog = false, isCheckSession = false)
@RequestMapping("/listOnlineUser.xml")
public void listOnlineUserXML(HttpServletRequest request, HttpServletResponse response) throws Exception {
    request.setCharacterEncoding("UTF-8");
    ListOnlineUserResponse resp = new ListOnlineUserResponse();

    try {// w ww . ja v  a2  s .com
        UserSessionParameter param = new UserSessionParameter();
        param.setStart(0);
        param.setLimit(9999);
        List<UserSessionVO> sessions = userManager.listUserSession(param);
        List<ListOnlineUserResponse.User> users = new ArrayList<ListOnlineUserResponse.User>();

        List<EpClientGateway> list = epClientGatewayManager.listEpClientGateway();
        for (EpClientGateway ecg : list) {
            if (!StringUtils.isBlank(ecg.getNaming())) {
                resp.setClientGatewayIp(ecg.getIp1());
                resp.setClientGatewayPort(ecg.getPort().toString());
                break;
            }
        }
        for (UserSessionVO us : sessions) {
            ListOnlineUserResponse.User user = resp.new User();
            user.setNaming(us.getNaming());
            user.setSessionId(us.getId());
            users.add(user);
        }

        resp.setUsers(users);
    } catch (Exception e) {
        e.printStackTrace();
        resp.setSuccess(ListOnlineUserResponse.EXCEPTION);
    }

    Document doc = new Document();
    Element root = new Element("Message");
    doc.setRootElement(root);

    Element successElement = new Element("Success");
    successElement.setText(resp.getSuccess());
    root.addContent(successElement);

    Element usersElement = new Element("Users");
    root.addContent(usersElement);

    for (ListOnlineUserResponse.User user : resp.getUsers()) {
        Element userElement = new Element("User");
        userElement.setAttribute("SessionId", user.getSessionId());
        userElement.setAttribute("Naming", user.getNaming() == null ? "" : user.getNaming());
        userElement.setAttribute("SessionId", user.getSessionId());
        userElement.setAttribute("SessionId", user.getSessionId());
        userElement.setAttribute("ClientGatewayIp", resp.getClientGatewayIp());
        userElement.setAttribute("ClientGatewayPort", resp.getClientGatewayPort());
        usersElement.addContent(userElement);
    }

    writePageWithContentLength(response, doc);
}

From source file:es.logongas.encuestas.presentacion.controller.EncuestaController.java

@RequestMapping(value = { "/pregunta.html" })
public ModelAndView pregunta(HttpServletRequest request, HttpServletResponse response) throws Exception {
    Map<String, Object> model = new HashMap<String, Object>();
    String viewName;/*from w  w  w  .  j av  a  2 s  .c  om*/

    if (request.getCharacterEncoding() == null) {
        try {
            request.setCharacterEncoding("utf-8");
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(EncuestaController.class.getName()).log(Level.WARNING,
                    "no existe el juego de caracteres utf-8", ex);
        }
    }

    int idPregunta;
    try {
        idPregunta = Integer.parseInt(request.getParameter("idPregunta"));
    } catch (NumberFormatException ex) {
        throw new BusinessException(
                new BusinessMessage(null, "El N de pregunta no es vlido.No es un nmero"));
    }

    Pregunta pregunta = (Pregunta) daoFactory.getDAO(Pregunta.class).read(idPregunta);
    if (pregunta == null) {
        throw new BusinessException(new BusinessMessage(null, "La pregunta solicitada no existe"));
    }

    if (getEncuestaState(request).getRespuestaEncuesta().isPreguntaValida(pregunta) == false) {
        throw new BusinessException(
                new BusinessMessage(null, "La pregunta solicitada no es vlida en esta encuesta"));
    }

    RespuestaPregunta respuestaPregunta = getEncuestaState(request).getRespuestaEncuesta()
            .getRespuestaPregunta(pregunta);
    model.put("respuestaPregunta", respuestaPregunta);
    viewName = "encuestas/pregunta";

    return new ModelAndView(viewName, model);
}

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

@Override
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 path = WebUtils.getString(request, "path");
    String uuid = WebUtils.getString(request, "uuid");
    updateSessionManager(request);/* w  ww. j a v  a 2s  . co  m*/

    try {
        if (uuid != null && !uuid.isEmpty()) {
            path = NodeBaseDAO.getInstance().getPathFromUuid(uuid);
        } else if (path != null && !path.isEmpty()) {
            uuid = NodeBaseDAO.getInstance().getUuidFromPath(path);
        }

        if (action.equals("unlock")) {
            unlock(uuid, path, request, response);
        } else if (action.equals("checkin")) {
            // checkin(session, path, request, response);
        } else if (action.equals("remove_content")) {
            removeContent(uuid, path, request, response);
        } else if (action.equals("remove_current")) {
            uuid = removeCurrent(uuid, path, request, response);
            path = NodeBaseDAO.getInstance().getPathFromUuid(uuid);
        } else if (action.equals("remove_pgroup")) {
            // removePropGrup(session, path, request, response);
        } else if (action.equals("edit")) {
            edit(uuid, path, request, response);
        } else if (action.equals("downloadVersion")) {
            downloadVersion(uuid, request, response);
        } else if (action.equals("diff")) {
            diff(uuid, request, response);
        } else if (action.equals("forceTextExtraction")) {
            forceTextExtraction(uuid, path, request, response);
        }

        if (!action.equals("edit") && !action.equals("downloadVersion") && !action.equals("diff")) {
            list(uuid, path, request, response);
        }
    } catch (PathNotFoundException e) {
        log.error(e.getMessage(), e);
        sendErrorRedirect(request, response, e);
    } catch (AccessDeniedException e) {
        log.error(e.getMessage(), e);
        sendErrorRedirect(request, response, e);
    } catch (LockException e) {
        log.error(e.getMessage(), e);
        sendErrorRedirect(request, response, e);
    } 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);
    }
}

From source file:es.logongas.encuestas.presentacion.controller.EncuestaController.java

@RequestMapping(value = { "/finalizar.html" })
public ModelAndView finalizar(HttpServletRequest request, HttpServletResponse response) throws Exception {
    Map<String, Object> model = new HashMap<String, Object>();
    String viewName;/*  w w w  .j a  v a 2s  .  c  o m*/

    if (request.getCharacterEncoding() == null) {
        try {
            request.setCharacterEncoding("utf-8");
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(EncuestaController.class.getName()).log(Level.WARNING,
                    "no existe el juego de caracteres utf-8", ex);
        }
    }

    RespuestaEncuesta respuestaEncuesta = getEncuestaState(request).getRespuestaEncuesta();

    List<BusinessMessage> businessMessages = respuestaEncuesta.validate();
    if ((businessMessages != null) && (businessMessages.size() > 0)) {
        Encuesta encuesta = respuestaEncuesta.getEncuesta();
        model.put("encuesta", encuesta);
        model.put("businessMessages", businessMessages);
        viewName = "encuestas/error_encuesta";
    } else {
        Date fechaRespuesta = new Date();
        respuestaEncuesta.setFechaRespuesta(fechaRespuesta);
        respuestaEncuesta.setCurso(getCursoFromDate(fechaRespuesta));

        daoFactory.getDAO(RespuestaEncuesta.class).insert(respuestaEncuesta);
        CodigoVerificacionSeguro codigoVerificacionSeguro = CodigoVerificacionSeguro
                .getInstance(respuestaEncuesta.getIdRespuestaEncuesta());
        respuestaEncuesta.setCodigoVerificacionSeguro(codigoVerificacionSeguro);
        daoFactory.getDAO(RespuestaEncuesta.class).update(respuestaEncuesta);

        URI backURI = getEncuestaState(request).getBackURI();

        clearEncuestaState(request);

        model.put("codigoVerificacionSeguro", codigoVerificacionSeguro);
        model.put("backURI", backURI);
        viewName = "encuestas/finalizar";
    }

    return new ModelAndView(viewName, model);
}

From source file:es.logongas.encuestas.presentacion.controller.EncuestaController.java

@RequestMapping(value = { "/anterior.html" })
public ModelAndView anterior(HttpServletRequest request, HttpServletResponse response) throws Exception {
    Map<String, Object> model = new HashMap<String, Object>();
    String viewName;/* w  w  w .  j av  a  2 s. co  m*/

    if (request.getCharacterEncoding() == null) {
        try {
            request.setCharacterEncoding("utf-8");
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(EncuestaController.class.getName()).log(Level.WARNING,
                    "no existe el juego de caracteres utf-8", ex);
        }
    }

    int idPregunta;
    try {
        idPregunta = Integer.parseInt(request.getParameter("idPregunta"));
    } catch (NumberFormatException ex) {
        throw new BusinessException(new BusinessMessage(null, "El N de pregunta no es vlido"));
    }

    Pregunta pregunta = (Pregunta) daoFactory.getDAO(Pregunta.class).read(idPregunta);
    if (pregunta == null) {
        throw new BusinessException(new BusinessMessage(null, "La pregunta solicitada no existe"));
    }

    RespuestaEncuesta respuestaEncuesta = getEncuestaState(request).getRespuestaEncuesta();
    if (respuestaEncuesta.isPreguntaValida(pregunta) == false) {
        throw new BusinessException(
                new BusinessMessage(null, "La pregunta solicitada no es vlida en esta encuesta"));
    }

    RespuestaPregunta respuestaPregunta = respuestaEncuesta.getRespuestaPregunta(pregunta);
    populateRespuestaFromRequest(request, respuestaPregunta);

    Pregunta anteriorPregunta = respuestaEncuesta.getRespuestaPregunta(pregunta).anterior();

    if (anteriorPregunta != null) {
        viewName = "redirect:/pregunta.html?idPregunta=" + anteriorPregunta.getIdPregunta();
    } else {
        //Era la primera pregunta
        //As que vamos al BackURL
        viewName = "redirect:" + getEncuestaState(request).getBackURI().toASCIIString();
    }

    return new ModelAndView(viewName, model);
}

From source file:org.mapfish.print.servlet.MapPrinterServlet.java

/**
 * All in one method: create and returns the PDF to the client. Avoid to use
 * it, the accents in the spec are not all supported.
 *///from  ww w  .  jav a2s .  co m
protected void createAndGetPDF(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
    //get the spec from the query
    TempFile tempFile = null;
    String spec = null;
    try {
        httpServletRequest.setCharacterEncoding("UTF-8");
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }
    if (httpServletRequest.getMethod() == "POST") {
        try {
            spec = getSpecFromPostBody(httpServletRequest);
        } catch (IOException e) {
            error(httpServletResponse, "Missing 'spec' in request body", 500);
            return;
        }
    } else {
        spec = httpServletRequest.getParameter("spec");
    }
    if (spec == null) {
        error(httpServletResponse, "Missing 'spec' parameter", 500);
        return;
    }

    try {
        tempFile = doCreatePDFFile(spec, httpServletRequest);
        sendPdfFile(httpServletResponse, tempFile,
                Boolean.parseBoolean(httpServletRequest.getParameter("inline")));
    } catch (Throwable e) {
        error(httpServletResponse, e);
    } finally {
        deleteFile(tempFile);
    }
}