Example usage for javax.servlet ServletOutputStream println

List of usage examples for javax.servlet ServletOutputStream println

Introduction

In this page you can find the example usage for javax.servlet ServletOutputStream println.

Prototype


public void println(double d) throws IOException 

Source Link

Document

Writes a double value to the client, followed by a carriage return-line feed (CRLF).

Usage

From source file:pivotal.au.se.gemfirexdweb.controller.TypeController.java

@RequestMapping(value = "/types", method = RequestMethod.POST)
public String performTypeAction(Model model, HttpServletResponse response, HttpServletRequest request,
        HttpSession session) throws Exception {
    if (session.getAttribute("user_key") == null) {
        logger.debug("user_key is null new Login required");
        response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login");
        return null;
    } else {/*  w ww  . j a  va2s  .  com*/
        Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key"));
        if (conn == null) {
            response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login");
            return null;
        } else {
            if (conn.isClosed()) {
                response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login");
                return null;
            }
        }

    }

    int startAtIndex = 0, endAtIndex = 0;
    String schema = null;
    Result result = new Result();
    List<Type> types = null;
    String ddlString = null;

    logger.debug("Received request to perform an action on the types");

    TypeDAO typeDAO = GemFireXDWebDAOFactory.getTypeDAO();

    String selectedSchema = request.getParameter("selectedSchema");
    logger.debug("selectedSchema = " + selectedSchema);

    if (selectedSchema != null) {
        schema = selectedSchema;
    } else {
        schema = (String) session.getAttribute("schema");
    }

    logger.debug("schema = " + schema);

    if (request.getParameter("search") != null) {
        types = typeDAO.retrieveTypeList(schema, (String) request.getParameter("search"),
                (String) session.getAttribute("user_key"));

        model.addAttribute("search", (String) request.getParameter("search"));
    } else {
        String[] tableList = request.getParameterValues("selected_type[]");
        String commandStr = request.getParameter("submit_mult");

        logger.debug("tableList = " + Arrays.toString(tableList));
        logger.debug("command = " + commandStr);

        // start actions now if tableList is not null

        if (tableList != null) {
            List al = new ArrayList<Result>();
            List<String> al2 = new ArrayList<String>();

            for (String type : tableList) {
                if (commandStr.equalsIgnoreCase("DDL") || commandStr.equalsIgnoreCase("DDL_FILE")) {
                    ddlString = typeDAO.generateDDL(schema, type, (String) session.getAttribute("user_key"));
                    al2.add(ddlString);
                } else {
                    result = null;
                    result = typeDAO.simpletypeCommand(schema, type, commandStr,
                            (String) session.getAttribute("user_key"));
                    al.add(result);
                }
            }

            if (commandStr.equalsIgnoreCase("DDL")) {
                request.setAttribute("arrayresultddl", al2);
            } else if (commandStr.equalsIgnoreCase("DDL_FILE")) {
                response.setContentType(SAVE_CONTENT_TYPE);
                response.setHeader("Content-Disposition",
                        "attachment; filename=" + String.format(FILENAME, "TypeDDL"));

                ServletOutputStream out = response.getOutputStream();
                for (String ddl : al2) {
                    out.println(ddl);
                }

                out.close();
                return null;
            } else {
                model.addAttribute("arrayresult", al);
            }
        }

        types = typeDAO.retrieveTypeList(schema, null, (String) session.getAttribute("user_key"));
    }

    model.addAttribute("records", types.size());
    model.addAttribute("estimatedrecords", types.size());

    UserPref userPref = (UserPref) session.getAttribute("prefs");

    if (types.size() <= userPref.getRecordsToDisplay()) {
        model.addAttribute("types", types);
    } else {
        if (request.getParameter("startAtIndex") != null) {
            startAtIndex = Integer.parseInt(request.getParameter("startAtIndex"));
        }

        if (request.getParameter("endAtIndex") != null) {
            endAtIndex = Integer.parseInt(request.getParameter("endAtIndex"));
            if (endAtIndex > types.size()) {
                endAtIndex = types.size();
            }
        } else {
            endAtIndex = userPref.getRecordsToDisplay();
        }

        List subList = types.subList(startAtIndex, endAtIndex);
        model.addAttribute("types", subList);
    }

    model.addAttribute("startAtIndex", startAtIndex);
    model.addAttribute("endAtIndex", endAtIndex);

    model.addAttribute("schemas", GemFireXDWebDAOUtil.getAllSchemas((String) session.getAttribute("user_key")));

    model.addAttribute("chosenSchema", schema);

    // This will resolve to /WEB-INF/jsp/types.jsp
    return "types";
}

From source file:org.inbio.ait.web.ajax.controller.SelectAllController.java

private ModelAndView writeReponse(HttpServletRequest request, HttpServletResponse response, List<Polygon> pList)
        throws Exception {

    response.setCharacterEncoding("ISO-8859-1");
    response.setContentType("text/xml");
    // Binary output
    ServletOutputStream out = response.getOutputStream();

    if (pList != null) {
        StringBuilder result = new StringBuilder();
        result.append("<?xml version='1.0' encoding='ISO-8859-1'?><response>");
        for (Polygon p : pList) {
            result.append("<polygon><id>" + p.getId() + "</id>");
            result.append("<name>" + p.getName() + "</name></polygon>");
        }//from  w ww. j a v a  2  s  . c  om
        result.append("</response>");
        out.println(result.toString());
    }

    out.flush();
    out.close();

    return null;
}

From source file:org.spiffyui.hellospiffyauth.server.SampleAuthServer.java

@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String authHeader = request.getHeader(AUTHORIZATION);
    response.setContentType("application/json");

    ServletOutputStream out = response.getOutputStream();
    StringBuffer buff = new StringBuffer();

    if (authHeader == null) {
        /*//from  w  w  w  .  j  a  v  a 2s .  c o  m
         * This means someone tried to get a token but didn't specify any credentials
         */
        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
        buff.append(generateFault("Sender", "NoAuthHeader", ""));
        out.println(buff.toString());
        return;
    }

    String[] fields = authHeader.trim().split(" ");
    if (fields.length != 2) {
        /*
         * This means someone specified an invalid authorization header
         */
        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
        buff.append(generateFault("Sender", "InvalidAuthHeader", "The authorization header '" + authHeader
                + "' is invalid.  " + "The format should be BASIC <username:password> base64 encoded."));
        out.println(buff.toString());
        return;
    }
    String cred;
    try {
        cred = new String(Base64.decodeBase64(fields[1].getBytes("UTF-8")), "UTF-8");
    } catch (UnsupportedEncodingException e) {
        throw new IllegalStateException(e);
    }
    String[] creds = cred.split(":");
    if (creds.length != 2) {
        /*
         * This means someone specified an invalid authorization header
         */
        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
        buff.append(generateFault("Sender", "InvalidAuthHeader", "The authorization header '" + authHeader
                + "' is invalid.  " + "The format should be BASIC <username:password> base64 encoded."));
        out.println(buff.toString());
        return;
    }

    /*
     * At this point we can generate our token.  In our case we just use the username followed
     * by a random number.  The token can be any format.
     */
    String random = Long.toHexString(Double.doubleToLongBits(Math.random()));
    buff.append("{\"Token\":\"" + creds[0] + "-" + random + "\"}");

    out.println(buff.toString());
}

From source file:org.openmrs.web.servlet.SampleFlowsheetServlet.java

protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    log.debug("Getting sample flowsheet");

    response.setContentType("text/html");
    HttpSession session = request.getSession();

    String pid = request.getParameter("pid");
    if (pid == null || pid.length() == 0) {
        session.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "error.null");
        return;/*from  www  .  j  a  va 2  s  . com*/
    }

    if (!Context.isAuthenticated() || !Context.hasPrivilege(PrivilegeConstants.GET_PATIENTS)
            || !Context.hasPrivilege(PrivilegeConstants.GET_OBS)) {
        session.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, "Privileges required: "
                + PrivilegeConstants.GET_PATIENTS + " and " + PrivilegeConstants.GET_OBS);
        session.setAttribute(WebConstants.OPENMRS_LOGIN_REDIRECT_HTTPSESSION_ATTR,
                request.getRequestURI() + "?" + request.getQueryString());
        response.sendRedirect(request.getContextPath() + "/login.htm");
        return;
    }

    ServletOutputStream out = response.getOutputStream();

    Integer patientId = Integer.parseInt(pid);
    Patient patient = Context.getPatientService().getPatient(patientId);
    List<Obs> obsList = Context.getObsService().getObservationsByPerson(patient);

    if (obsList == null || obsList.size() < 1) {
        out.print("No observations found");
        return;
    }

    out.println("<style>");
    out.println(".header { font-family:Arial; font-weight:bold; text-align: center; font-size: 1.5em;}");
    out.println(
            ".label { font-family:Arial; text-align:right; color:#808080; font-style:italic; font-size: 0.6em; vertical-align: top;}");
    out.println(".value { font-family:Arial; text-align:left; vertical-align:top; }");
    out.println("</style>");
    out.println("<table cellspacing=0 cellpadding=3>");
    Locale locale = Context.getLocale();
    Calendar date = Calendar.getInstance();
    date.set(1900, Calendar.JANUARY, 1);
    Calendar obsDate = Calendar.getInstance();
    for (Obs obs : obsList) {
        obsDate.setTime(obs.getObsDatetime());
        if (Math.abs(obsDate.getTimeInMillis() - date.getTimeInMillis()) > 86400000) {
            date = obsDate;
            out.println("<tr><td class=header colspan=2>" + Context.getDateFormat().format(date.getTime())
                    + "</td></tr>");
        }
        StringBuilder s = new StringBuilder("<tr><td class=label>");
        s.append(getName(obs, locale));
        s.append("</td><td class=value>");
        s.append(getValue(obs, locale));
        s.append("</td></tr>");
        out.println(s.toString());
    }
    out.println("</table>");
}

From source file:org.inbio.ait.web.ajax.controller.IndicatorsTreeController.java

private ModelAndView writeReponse(HttpServletRequest request, HttpServletResponse response,
        List<AutocompleteNode> acnList) throws Exception {

    response.setCharacterEncoding("ISO-8859-1");
    response.setContentType("text/xml");
    // Binary output
    ServletOutputStream out = response.getOutputStream();

    if (acnList != null) {
        StringBuilder result = new StringBuilder();
        result.append("<?xml version='1.0' encoding='ISO-8859-1'?><response>");
        for (AutocompleteNode sp : acnList) {
            result.append("<node><id>" + sp.getItemId() + "</id>");
            result.append("<name>" + sp.getItemName() + "</name></node>");
        }/*from   ww w  .j  av a 2  s  .co  m*/
        result.append("</response>");
        out.println(result.toString());
    }

    out.flush();
    out.close();

    return null;
}

From source file:org.my.eaptest.UploadServlet.java

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    resp.setContentType("text/html;charset=UTF-8");
    ServletOutputStream out = resp.getOutputStream();

    // Check that we have a file upload request.
    if (!ServletFileUpload.isMultipartContent(req)) {
        out.println(
                "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">");
        out.println("<html>");
        out.println("<head>");
        out.println("<title>Servlet upload</title>");
        out.println("</head>");
        out.println("<body>");
        out.println("<p>No file uploaded!</p>");
        out.println("</body>");
        out.println("</html>");

        return;/*  w  ww . j  a va2  s .  com*/
    }

    // Create a factory for disk-based file items.
    DiskFileItemFactory factory = new DiskFileItemFactory();
    // Configure a repository (to ensure a secure temp location is used).
    ServletContext servletContext = this.getServletConfig().getServletContext();
    File repository = (File) servletContext.getAttribute("javax.servlet.context.tempdir");
    factory.setRepository(repository);
    // Maximum size that will be stored in memory.
    factory.setSizeThreshold(MAX_FILE_SIZE);
    // Create a new file upload handler
    ServletFileUpload upload = new ServletFileUpload(factory);

    // Parse the request to get file items.
    try {
        List<FileItem> items = upload.parseRequest(req);

        out.println(
                "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">");
        out.println("<html>");
        out.println("<head>");
        out.println("<title>Servlet upload</title>");
        out.println("</head>");
        out.println("<body>");
        out.println("<div style=\"text-align: left;\">");
        // we look for a filename item and/or file item with file content
        Iterator<FileItem> iter = items.iterator();
        String filename = null;
        String contents = null;
        boolean delete = false;
        while (iter.hasNext()) {
            FileItem item = iter.next();
            boolean isFormField = item.isFormField();
            String fieldName = item.getFieldName();
            if (isFormField && fieldName.equals("filename")) {
                String name = item.getString();
                if (name.length() > 0 || filename == null) {
                    filename = name;
                }
            } else if (isFormField && fieldName.equals("readonly")) {
                // means no filename or file provided
            } else if (isFormField && fieldName.equals("delete")) {
                // delete one or all fiels depending on whether filename is provided
                delete = true;
            } else if (!isFormField && fieldName.equals("file")) {
                contents = fromStream(item.getInputStream());
                contents = StringEscapeUtils.escapeHtml(contents);
                if (filename == null || filename.length() == 0) {
                    filename = item.getName();
                }
            } else {
                if (isFormField) {
                    out.print("<p><pre>Unexpected field name : ");
                    out.print(fieldName);
                    out.println("</pre>");
                } else {
                    String name = item.getName();
                    out.print("<p><pre>Unexpected file item : ");
                    out.print(name);
                    out.print(" for field ");
                    out.print(fieldName);
                    out.println("</pre>");
                }
                out.println("</body>");
                out.println("</html>");
                return;
            }
        }

        // if we don't have a filename then either list or delete all files in the hashtable

        if (filename == null) {
            if (delete) {
                filedata.clear();
                out.println("All files deleted!<br/>");
            } else {
                Set<String> keys = filedata.keySet();
                out.println("All files:<br/>");
                out.println("<pre>");
                if (keys.isEmpty()) {
                    out.println("No files found!");
                } else {
                    for (String key : keys) {
                        out.print(key);
                        FileSet set = filedata.get(key);
                        if (set != null) {
                            out.print(" ");
                            out.println(set.size());
                        } else {
                            out.println(" 0");
                        }
                    }
                }
                out.println("</pre>");
            }
            out.println("</body>");
            out.println("</html>");
            return;
        }
        // if we have a filename and no contents then we
        // retrieve the file contents from the hashmap
        // and maybe delete the file
        // if we have a filename and contents then we update
        // the hashmap -- delete should not be supplied in
        // this case

        boolean noUpdate = (contents == null);
        if (noUpdate) {
            if (delete) {
                FileSet set = filedata.remove(filename);
                contents = (set != null ? set.get() : null);
            } else {
                FileSet set = filedata.get(filename);
                contents = (set != null ? set.get() : null);
            }
        } else {
            FileSet set = new FileSet();
            FileSet old = filedata.putIfAbsent(filename, set);
            if (old != null) {
                set = old;
            }
            set.add(contents);
        }

        // now hand the contents back
        out.print("<pre>File: ");
        out.print(filename);
        boolean printContents = true;
        if (noUpdate) {
            if (contents == null) {
                out.println(" not found");
                printContents = false;
            } else if (delete) {
                out.print(" deleted");
            }
        } else {
            if (contents == null) {
                out.print(" added");
            } else {
                out.print(" updated");
            }
        }
        out.println("</pre><br/>");
        if (printContents) {
            out.println("<pre>");
            out.println(contents);
            out.println("</pre>");
        }
        out.println("</body>");
        out.println("</html>");
    } catch (FileUploadException fuEx) {
        log.error("Problem with process file upload:", fuEx);
    }
}

From source file:org.inbio.ait.web.ajax.controller.QueryController.java

/**
 * Write the XML to be parsed on the analysis view
 * Case 0: If there is just one criteria category or especifically these categories
 * (geographical-taxonomical or or taxonomical-indicator). It means type 0 on xml
 * @param request/*from   ww  w . j av  a  2s. com*/
 * @param response
 * @param totalMatch
 * @param matchesByPolygon
 * @return
 * @throws java.lang.Exception
 */
private ModelAndView writeReponse0(HttpServletRequest request, HttpServletResponse response, Long totalMatch,
        Long totalPercentage) throws Exception {

    response.setCharacterEncoding("ISO-8859-1");
    response.setContentType("text/xml");
    ServletOutputStream out = response.getOutputStream();

    StringBuilder result = new StringBuilder();
    result.append("<?xml version='1.0' encoding='ISO-8859-1'?><response>");
    result.append("<type>0</type>");
    result.append("<total>" + totalMatch + "</total>");
    result.append("<totalp>" + totalPercentage + "</totalp></response>");

    out.println(result.toString());
    out.flush();
    out.close();

    return null;
}

From source file:org.expath.servlex.rest.DeployWebapp.java

/**
 * Deploy a XAR or a XAW file./*from www  .j a v  a2  s .co  m*/
 * 
 * @param req The HTTP request object.
 * 
 * @param resp The HTTP response object.
 * 
 * @throws IOException In case of any I/O error.
 * 
 * @throws ServletException In case of any other error.
 */
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
    resp.setContentType("application/xml");
    resp.setCharacterEncoding("UTF-8");
    ServletOutputStream out = resp.getOutputStream();
    try {
        if (!myRepo.canInstall()) {
            error(501, "Not Implemented", "Install not supported, storage is read-only.");
        }
        // name will be null if the package is not a webapp
        String name = doInstall(req);
        out.println("<success>");
        if (name == null) {
            out.print("   <msg>The package");
        } else {
            out.print("   <msg>The webapp at ");
            out.print(name);
        }
        out.println(" has been successfully installed.</msg>");
        out.println("</success>");
    } catch (RestError ex) {
        out.println("<error>");
        out.println("   <msg>" + ex.getUserMessage() + "</msg>");
        out.println("</error>");
        ex.sendError(resp);
    } catch (ServlexException ex) {
        out.println("<error>");
        out.println("   <msg>Unexpected exception: " + ex.getMessage() + "</msg>");
        out.println("</error>");
        ex.sendError(resp);
    } catch (RuntimeException ex) {
        out.println("<error>");
        out.println("   <msg>Unexpected runtime error: " + ex.getMessage() + "</msg>");
        out.println("   <msg>Please report this to the mailing list, see Servlex logs");
        out.println("      for additional information about the error.</msg>");
        out.println("</error>");
        resp.sendError(500, "Internal Server Error");
    }
}

From source file:guru.nidi.raml.doc.servlet.MirrorServlet.java

@Override
protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    final int delay = req.getParameter("delay") == null ? 0 : Integer.parseInt(req.getParameter("delay"));
    try {//from w  ww . j  a  v  a  2  s.c om
        Thread.sleep(delay);
    } catch (InterruptedException e) {
        //ignore
    }
    final String q = req.getParameter("q") == null ? "" : req.getParameter("q");
    if (q.equals("png")) {
        final ServletOutputStream out = res.getOutputStream();
        res.setContentType("image/png");
        copy(getClass().getClassLoader().getResourceAsStream("data/google.png"), out);
    } else {
        final PrintWriter out = res.getWriter();
        switch (q) {
        case "html":
            res.setContentType("text/html");
            out.print("<html><body><ul>");
            for (int i = 0; i < 50; i++) {
                out.println("<li>" + i + "</li>");
            }
            out.print("</ul></body></html>");
            break;
        case "json":
            res.setContentType("application/json");
            final ObjectMapper mapper = new ObjectMapper();
            final Map<String, Object> map = new HashMap<>();
            map.put("method", req.getMethod());
            map.put("url", req.getRequestURL().toString());
            map.put("headers", headers(req));
            map.put("query", query(req));
            mapper.writeValue(out, map);
            break;
        case "error":
            res.sendError(500, "Dummy error message");
            break;
        default:
            out.println(req.getMethod() + " " + req.getRequestURL());
            headers(req, out);
            query(req, out);
            copy(req.getReader(), out);
        }
    }
    res.flushBuffer();
}

From source file:org.apache.cocoon.servlet.RequestProcessor.java

/**
 * Process the specified <code>HttpServletRequest</code> producing output
 * on the specified <code>HttpServletResponse</code>.
 *///from   w  ww  .  j a v  a  2  s .c o m
public void service(HttpServletRequest request, HttpServletResponse res) throws ServletException, IOException {
    // used for timing the processing
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();

    // add the cocoon version header stamp
    if (this.servletSettings.isShowVersion()) {
        res.addHeader("X-Cocoon-Version", Constants.VERSION);
    }

    // We got it... Process the request
    final String uri = getURI(request, res);
    if (uri == null) {
        // a redirect occured, so we are finished
        return;
    }

    Environment env;
    try {
        // Pass uri into environment without URLDecoding, as it is already decoded.
        env = getEnvironment(uri, request, res);
    } catch (Exception e) {
        if (getLogger().isErrorEnabled()) {
            getLogger().error("Problem with Cocoon servlet", e);
        }

        if (rethrowExceptions()) {
            throw new ServletException(e);
        }

        RequestUtil.manageException(request, res, null, uri, HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                "Problem in creating the Environment", null, null, e, this.servletSettings, getLogger(), this);
        return;
    }

    String contentType = null;
    try {
        if (process(env)) {
            contentType = env.getContentType();
        } else {
            // We reach this when there is nothing in the processing chain that matches
            // the request. For example, no matcher matches.
            getLogger().fatal("The Cocoon engine failed to process the request.");

            if (rethrowExceptions()) {
                throw new ServletException("The Cocoon engine failed to process the request.");
            }

            RequestUtil.manageException(request, res, env, uri, HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                    "Request Processing Failed", "Cocoon engine failed in processing the request",
                    "The processing engine failed to process the request. This could be due to lack of matching or bugs in the pipeline engine.",
                    null, this.servletSettings, getLogger(), this);
            return;
        }
    } catch (ResourceNotFoundException e) {
        if (getLogger().isDebugEnabled()) {
            getLogger().warn(e.getMessage(), e);
        } else if (getLogger().isWarnEnabled()) {
            getLogger().warn(e.getMessage());
        }

        if (rethrowExceptions()) {
            throw new ServletException(e);
        }

        RequestUtil.manageException(request, res, env, uri, HttpServletResponse.SC_NOT_FOUND,
                "Resource Not Found", "Resource Not Found",
                "The requested resource \"" + request.getRequestURI() + "\" could not be found", e,
                this.servletSettings, getLogger(), this);
        return;

    } catch (ConnectionResetException e) {
        if (getLogger().isDebugEnabled()) {
            getLogger().debug(e.toString(), e);
        } else if (getLogger().isWarnEnabled()) {
            getLogger().warn(e.toString());
        }

    } catch (IOException e) {
        // Tomcat5 wraps SocketException into ClientAbortException which extends IOException.
        if (getLogger().isDebugEnabled()) {
            getLogger().debug(e.toString(), e);
        } else if (getLogger().isWarnEnabled()) {
            getLogger().warn(e.toString());
        }

    } catch (Exception e) {
        if (getLogger().isErrorEnabled()) {
            getLogger().error("Internal Cocoon Problem", e);
        }

        if (rethrowExceptions()) {
            throw new ServletException(e);
        }

        RequestUtil.manageException(request, res, env, uri, HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                "Internal Server Error", null, null, e, this.servletSettings, getLogger(), this);
        return;
    }

    stopWatch.stop();
    String timeString = null;
    if (getLogger().isInfoEnabled()) {
        timeString = processTime(stopWatch.getTime());
        getLogger().info("'" + uri + "' " + timeString);
    }

    if (contentType != null && contentType.equals("text/html")) {
        String showTime = request.getParameter(Constants.SHOWTIME_PARAM);
        boolean show = this.servletSettings.isShowTime();
        if (showTime != null) {
            show = !showTime.equalsIgnoreCase("no");
        }
        if (show) {
            if (timeString == null) {
                timeString = processTime(stopWatch.getTime());
            }
            boolean hide = this.servletSettings.isHideShowTime();
            if (showTime != null) {
                hide = showTime.equalsIgnoreCase("hide");
            }
            ServletOutputStream out = res.getOutputStream();
            out.print((hide) ? "<!-- " : "<p>");
            out.print(timeString);
            out.println((hide) ? " -->" : "</p>");
        }
    }

    /*
     * Servlet Specification 2.2, 6.5 Closure of Response Object:
     *
     *   A number of events can indicate that the servlet has provided all of the
     *   content to satisfy the request and that the response object can be
     *   considered to be closed. The events are:
     *     o The termination of the service method of the servlet.
     *     o When the amount of content specified in the setContentLength method
     *       of the response has been written to the response.
     *     o The sendError method is called.
     *     o The sendRedirect method is called.
     *   When a response is closed, all content in the response buffer, if any remains,
     *   must be immediately flushed to the client.
     *
     * Due to the above, out.flush() and out.close() are not necessary, and sometimes
     * (if sendError or sendRedirect were used) request may be already closed.
     */
}