vgritsenko    01/08/14 08:59:49

  Modified:    src/org/apache/cocoon/servlet CocoonServlet.java
  Log:
  Show time only for text/html.
  
  Revision  Changes    Path
  1.29      +9 -11     xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java
  
  Index: CocoonServlet.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/servlet/CocoonServlet.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- CocoonServlet.java        2001/08/13 08:40:38     1.28
  +++ CocoonServlet.java        2001/08/14 15:59:48     1.29
  @@ -64,7 +64,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Nicola Ken Barozzi</a> Aisa
    * @author <a href="mailto:[EMAIL PROTECTED]";>Berin Loritsch</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.28 $ $Date: 2001/08/13 08:40:38 $
  + * @version CVS $Revision: 1.29 $ $Date: 2001/08/14 15:59:48 $
    */
   
   public class CocoonServlet extends HttpServlet {
  @@ -177,6 +177,7 @@
           // get allow reload parameter, default is true
           String value = conf.getInitParameter("allow-reload");
           this.allowReload = (value == null || value.equals("yes") || 
value.equals("true"));
  +
           if(conf.getInitParameter("allow-reload") == null) {
              log.debug("allow-reload was not set - defaulting to true");
           }
  @@ -514,7 +515,7 @@
               return;
           }
   
  -        boolean processed = false;
  +        String contentType = null;
           try {
               if (uri.charAt(0) == '/') {
                   uri = uri.substring(1);
  @@ -532,9 +533,8 @@
               ctxMap.set("objectModel", env.getObjectModel());
   
               if (this.cocoon.process(env)) {
  -                processed = true;
  +                contentType = env.getContentType();
               } else {
  -
                   // means SC_NOT_FOUND
                   res.setStatus(res.SC_NOT_FOUND);
   
  @@ -594,16 +594,14 @@
               n.setSource("Cocoon servlet");
               n.addExtraDescription("request-uri", request.getRequestURI());
               n.addExtraDescription("path-info", uri);
  -            res.setContentType(Notifier.notify(n, res.getOutputStream()));
  +            res.setContentType(contentType = Notifier.notify(n, 
res.getOutputStream()));
           }
   
           long end = new Date().getTime();
           String timeString = processTime(end - start);
           log.info("'" + uri + "' " + timeString);
   
  -        if (processed) {
  -            ServletOutputStream out = res.getOutputStream();
  -
  +        if (contentType != null && contentType.equals("text/html")) {
               String showTime = request.getParameter(Constants.SHOWTIME_PARAM);
               boolean show = this.showTime;
               if (showTime != null)
  @@ -612,13 +610,13 @@
                   boolean hide = this.hiddenShowTime;
                   if(showTime != null)
                       hide = showTime.equalsIgnoreCase("hide");
  +                ServletOutputStream out = res.getOutputStream();
                   out.print((hide) ? "<!-- " : "<p>");
                   out.print(timeString);
                   out.println((hide) ? " -->" : "</p>");
  +                out.flush();
  +                out.close();
               }
  -
  -            out.flush();
  -            out.close();
           }
       }
   
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to