vgritsenko 02/02/20 16:02:05
Modified: src/java/org/apache/cocoon/servlet CocoonServlet.java
Log:
Clear map after printing info
Revision Changes Path
1.11 +96 -94
xml-cocoon2/src/java/org/apache/cocoon/servlet/CocoonServlet.java
Index: CocoonServlet.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/servlet/CocoonServlet.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- CocoonServlet.java 20 Feb 2002 10:38:46 -0000 1.10
+++ CocoonServlet.java 21 Feb 2002 00:02:05 -0000 1.11
@@ -120,7 +120,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Leo Sutic</a>
- * @version CVS $Id: CocoonServlet.java,v 1.10 2002/02/20 10:38:46 tcurdt Exp $
+ * @version CVS $Id: CocoonServlet.java,v 1.11 2002/02/21 00:02:05 vgritsenko Exp $
*/
public class CocoonServlet extends HttpServlet {
@@ -940,35 +940,57 @@
String contentType = null;
ContextMap ctxMap = null;
try {
- if (uri.charAt(0) == '/') {
- uri = uri.substring(1);
- }
+ try {
+ if (uri.charAt(0) == '/') {
+ uri = uri.substring(1);
+ }
- Environment env = this.getEnvironment(uri, request, res);
+ Environment env = this.getEnvironment(uri, request, res);
- // Initialize a fresh log context containing the object model : it
- // will be used by the CocoonLogFormatter
- ctxMap = org.apache.log.ContextMap.getCurrentContext();
- // Add thread name (default content for empty context)
- String threadName = Thread.currentThread().getName();
- ctxMap.set("threadName", threadName);
- // Add the object model
- ctxMap.set("objectModel", env.getObjectModel());
- // Add a unique request id (threadName + currentTime
- ctxMap.set("request-id", threadName + System.currentTimeMillis());
+ // Initialize a fresh log context containing the object model : it
+ // will be used by the CocoonLogFormatter
+ ctxMap = ContextMap.getCurrentContext();
+ // Add thread name (default content for empty context)
+ String threadName = Thread.currentThread().getName();
+ ctxMap.set("threadName", threadName);
+ // Add the object model
+ ctxMap.set("objectModel", env.getObjectModel());
+ // Add a unique request id (threadName + currentTime
+ ctxMap.set("request-id", threadName + System.currentTimeMillis());
+
+ if (this.cocoon.process(env)) {
+ contentType = env.getContentType();
+ } else {
+ // Should not get here!
+ // means SC_NOT_FOUND
+ res.sendError(res.SC_NOT_FOUND);
+
+ SimpleNotifyingBean n = new SimpleNotifyingBean(this);
+ n.setType("error");
+ n.setTitle("Resource not found");
+ n.setSource("Cocoon servlet");
+ n.setMessage("The requested resource not found.");
+ n.setDescription("The requested URI \""
+ + request.getRequestURI()
+ + "\" was not found.");
+ n.addExtraDescription("request-uri", request.getRequestURI());
+ n.addExtraDescription("path-info", uri);
+ // send the notification but don't include it in the output
stream
+ // as the status SC_NOT_FOUND is enough
+ res.setContentType(Notifier.notify(n, (OutputStream)null));
+ }
+ } catch (ResourceNotFoundException rse) {
+ if (log.isWarnEnabled()) {
+ log.warn("The resource was not found", rse);
+ }
- if (this.cocoon.process(env)) {
- contentType = env.getContentType();
- } else {
- // Should not get here!
- // means SC_NOT_FOUND
res.sendError(res.SC_NOT_FOUND);
SimpleNotifyingBean n = new SimpleNotifyingBean(this);
- n.setType("error");
+ n.setType("resource-not-found");
n.setTitle("Resource not found");
n.setSource("Cocoon servlet");
- n.setMessage("The requested resource not found.");
+ n.setMessage("Resource not found");
n.setDescription("The requested URI \""
+ request.getRequestURI()
+ "\" was not found.");
@@ -977,88 +999,68 @@
// send the notification but don't include it in the output stream
// as the status SC_NOT_FOUND is enough
res.setContentType(Notifier.notify(n, (OutputStream)null));
- }
- } catch (ResourceNotFoundException rse) {
- if (log.isWarnEnabled()) {
- log.warn("The resource was not found", rse);
- }
- res.sendError(res.SC_NOT_FOUND);
-
- SimpleNotifyingBean n = new SimpleNotifyingBean(this);
- n.setType("resource-not-found");
- n.setTitle("Resource not found");
- n.setSource("Cocoon servlet");
- n.setMessage("Resource not found");
- n.setDescription("The requested URI \""
- + request.getRequestURI()
- + "\" was not found.");
- n.addExtraDescription("request-uri", request.getRequestURI());
- n.addExtraDescription("path-info", uri);
- // send the notification but don't include it in the output stream
- // as the status SC_NOT_FOUND is enough
- res.setContentType(Notifier.notify(n, (OutputStream)null));
-
- } catch (ConnectionResetException cre) {
- if (log.isWarnEnabled()) {
- log.warn("The connection was reset", cre);
- }
-
- SimpleNotifyingBean n = new SimpleNotifyingBean(this);
- n.setType("error");
- n.setTitle("Resource not found");
- n.setSource("Cocoon servlet");
- n.setMessage("Resource not found");
- n.setDescription("The requested URI \""
- + request.getRequestURI()
- + "\" was not found.");
- n.addExtraDescription("request-uri", request.getRequestURI());
- n.addExtraDescription("path-info", uri);
- // send the notification but don't include it in the output stream
- // as the connection was reset anyway
- res.setContentType(Notifier.notify(n, (OutputStream)null));
- } catch (Exception e) {
- if (log.isErrorEnabled()) {
- log.error("Problem with servlet", e);
- }
- //res.setStatus(res.SC_INTERNAL_SERVER_ERROR);
+ } catch (ConnectionResetException cre) {
+ if (log.isWarnEnabled()) {
+ log.warn("The connection was reset", cre);
+ }
- HashMap extraDescriptions = new HashMap(2);
- extraDescriptions.put("request-uri", request.getRequestURI());
- extraDescriptions.put("path-info", uri);
+ SimpleNotifyingBean n = new SimpleNotifyingBean(this);
+ n.setType("error");
+ n.setTitle("Resource not found");
+ n.setSource("Cocoon servlet");
+ n.setMessage("Resource not found");
+ n.setDescription("The requested URI \""
+ + request.getRequestURI()
+ + "\" was not found.");
+ n.addExtraDescription("request-uri", request.getRequestURI());
+ n.addExtraDescription("path-info", uri);
+ // send the notification but don't include it in the output stream
+ // as the connection was reset anyway
+ res.setContentType(Notifier.notify(n, (OutputStream)null));
+ } catch (Exception e) {
+ if (log.isErrorEnabled()) {
+ log.error("Problem with servlet", e);
+ }
+ //res.setStatus(res.SC_INTERNAL_SERVER_ERROR);
- Notifying n=new DefaultNotifyingBuilder().build(
- this, e, "fatal","Internal server error","Cocoon
servlet",null,null,extraDescriptions);
+ HashMap extraDescriptions = new HashMap(2);
+ extraDescriptions.put("request-uri", request.getRequestURI());
+ extraDescriptions.put("path-info", uri);
- res.setContentType(contentType = Notifier.notify(n,
res.getOutputStream()));
- } finally {
- if (ctxMap != null) ctxMap.clear();
- }
+ Notifying n=new DefaultNotifyingBuilder().build(
+ this, e, "fatal","Internal server error","Cocoon
servlet",null,null,extraDescriptions);
- long end = System.currentTimeMillis();
- String timeString = processTime(end - start);
- if (log.isInfoEnabled()) {
- log.info("'" + uri + "' " + timeString);
- }
+ res.setContentType(contentType = Notifier.notify(n,
res.getOutputStream()));
+ }
- if (contentType != null && contentType.equals("text/html")) {
- String showTime = request.getParameter(Constants.SHOWTIME_PARAM);
- boolean show = this.showTime;
- if (showTime != null) {
- show = !showTime.equalsIgnoreCase("no");
+ long end = System.currentTimeMillis();
+ String timeString = processTime(end - start);
+ if (log.isInfoEnabled()) {
+ log.info("'" + uri + "' " + timeString);
}
- if (show) {
- boolean hide = this.hiddenShowTime;
+
+ if (contentType != null && contentType.equals("text/html")) {
+ String showTime = request.getParameter(Constants.SHOWTIME_PARAM);
+ boolean show = this.showTime;
if (showTime != null) {
- hide = showTime.equalsIgnoreCase("hide");
+ show = !showTime.equalsIgnoreCase("no");
+ }
+ if (show) {
+ 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();
}
- ServletOutputStream out = res.getOutputStream();
- out.print((hide) ? "<!-- " : "<p>");
- out.print(timeString);
- out.println((hide) ? " -->" : "</p>");
- out.flush();
- out.close();
}
+ } finally {
+ if (ctxMap != null) ctxMap.clear();
}
}
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]