vgritsenko    01/08/14 09:00:26

  Modified:    src/org/apache/cocoon/servlet Tag: cocoon_20_branch
                        CocoonServlet.java
  Log:
  Show time for text/html only.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.13.2.15 +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.13.2.14
  retrieving revision 1.13.2.15
  diff -u -r1.13.2.14 -r1.13.2.15
  --- CocoonServlet.java        2001/08/13 08:41:05     1.13.2.14
  +++ CocoonServlet.java        2001/08/14 16:00:25     1.13.2.15
  @@ -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.13.2.14 $ $Date: 2001/08/13 08:41:05 $
  + * @version CVS $Revision: 1.13.2.15 $ $Date: 2001/08/14 16:00:25 $
    */
   
   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