cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r599594 - in /cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-sample/src/main/java/org/apache/cocoon/servletservice: demo1/DemoServlet.java demo2/DemoServlet.java
Date Thu, 29 Nov 2007 22:06:24 GMT
Author: reinhard
Date: Thu Nov 29 14:06:23 2007
New Revision: 599594

URL: http://svn.apache.org/viewvc?rev=599594&view=rev
Log:
- pass attributes, headers and parameters from parent request to sub request
- expand sample

Modified:
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-sample/src/main/java/org/apache/cocoon/servletservice/demo1/DemoServlet.java
    cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-sample/src/main/java/org/apache/cocoon/servletservice/demo2/DemoServlet.java

Modified: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-sample/src/main/java/org/apache/cocoon/servletservice/demo1/DemoServlet.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-sample/src/main/java/org/apache/cocoon/servletservice/demo1/DemoServlet.java?rev=599594&r1=599593&r2=599594&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-sample/src/main/java/org/apache/cocoon/servletservice/demo1/DemoServlet.java
(original)
+++ cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-sample/src/main/java/org/apache/cocoon/servletservice/demo1/DemoServlet.java
Thu Nov 29 14:06:23 2007
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -39,7 +39,7 @@
 
     BeanFactory beanFactory;
     SourceResolver resolver;
-    
+
     /* (non-Javadoc)
      * @see javax.servlet.GenericServlet#init()
      */
@@ -51,7 +51,10 @@
 
     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
         String path = request.getPathInfo();
-        
+
+        request.setAttribute("foo", "bar");
+        System.out.println("x=" + request.getParameter("x"));
+
         if ("/test1".equals(path)) {
             response.setContentType("text/plain");
             String attr = this.getInitParameter("foo");
@@ -67,7 +70,7 @@
 
             response.setContentType("text/plain");
             OutputStream os = response.getOutputStream();
-            
+
             copy(is, os);
             is.close();
             os.close();
@@ -76,15 +79,18 @@
             InputStream is = source.getInputStream();
             response.setContentType("text/plain");
             OutputStream os = response.getOutputStream();
-            
+
             copy(is, os);
+            os.write(("\nContent From: " + this.getClass().getName() + "\n").getBytes());
+            os.write(("******************************************************************\n").getBytes());
+            os.write(("request.getAttribute(\"foo1\") [from main request]: " + request.getAttribute("foo1")).getBytes());
             is.close();
             os.close();
         } else {
             throw new ServletException("Unknown path " + path);
         }
     }
-    
+
     private static void copy(InputStream is, OutputStream os) throws IOException {
         int bytesRead = 0;
         byte buffer[] = new byte[512];

Modified: cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-sample/src/main/java/org/apache/cocoon/servletservice/demo2/DemoServlet.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-sample/src/main/java/org/apache/cocoon/servletservice/demo2/DemoServlet.java?rev=599594&r1=599593&r2=599594&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-sample/src/main/java/org/apache/cocoon/servletservice/demo2/DemoServlet.java
(original)
+++ cocoon/trunk/core/cocoon-servlet-service/cocoon-servlet-service-sample/src/main/java/org/apache/cocoon/servletservice/demo2/DemoServlet.java
Thu Nov 29 14:06:23 2007
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,7 +32,14 @@
     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
         response.setContentType("text/plain");
         PrintWriter writer = response.getWriter();
-        writer.println("Demo2");
+        writer.println("Content From: " + this.getClass().getName());
+        writer.println("******************************************************************");
+        writer.println("request.getAttribute(\"foo\"): " + request.getAttribute("foo"));
+        writer.println("request.getParameter(\"x\"): " + request.getParameter("x"));
+        writer.println("request.getHeader(\"User-Agent\"): " + request.getHeader("User-Agent"));
+        // set a request attribute
+        request.setAttribute("foo1", "bar1");
+        writer.println("request.getAttribute(\"foo1\") [from sub request]: " + request.getAttribute("foo1"));
         writer.close();
     }
 



Mime
View raw message