### Eclipse Workspace Patch 1.0
#P cocoon-servlet-service-impl
Index: src/main/java/org/apache/cocoon/servletservice/util/ServletServiceResponse.java
===================================================================
--- src/main/java/org/apache/cocoon/servletservice/util/ServletServiceResponse.java	(revision 731081)
+++ src/main/java/org/apache/cocoon/servletservice/util/ServletServiceResponse.java	(working copy)
@@ -20,6 +20,7 @@
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
+import java.net.URI;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
@@ -31,6 +32,7 @@
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletResponse;
 
+
 /**
  * Creates a {@link HttpServletResponse} object that is usable for internal block calls.
  *
@@ -45,6 +47,7 @@
     private boolean committed;
     private Locale locale;
     private int statusCode;
+    private URI url;
 
     private Map headers;
 
@@ -53,6 +56,11 @@
      */
     final SimpleDateFormat dateFormat = new SimpleDateFormat("EEE', 'dd' 'MMM' 'yyyy' 'HH:mm:ss' 'Z", Locale.US);
 
+    public ServletServiceResponse(URI url) {
+    	this.url = url;
+        headers = new HashMap();
+        statusCode = HttpServletResponse.SC_OK;
+    }
 
     public ServletServiceResponse() {
         headers = new HashMap();
@@ -83,23 +91,19 @@
     }
 
     public String encodeRedirectUrl(String url) {
-        // TODO Auto-generated method stub
-        return null;
+        return url;
     }
 
     public String encodeRedirectURL(String url) {
-        // TODO Auto-generated method stub
-        return null;
+        return url;
     }
 
     public String encodeUrl(String url) {
-        // TODO Auto-generated method stub
-        return null;
+        return url;
     }
 
     public String encodeURL(String url) {
-        // TODO Auto-generated method stub
-        return null;
+        return url;
     }
 
     public void flushBuffer() throws IOException {
@@ -191,8 +195,39 @@
     }
 
     public void sendRedirect(String location) throws IOException {
-        // TODO Auto-generated method stub
+    	
+        if (!location.startsWith("servlet:"))
+        {
+            StringBuffer buf = getRootURL(url);
+//            if (location.startsWith("/"))
+//                buf.append(URIUtil.canonicalPath(location));
+//            else
+//            {
+//                String path=url.getPath();
+//                String parent=(path.endsWith("/"))?path:URIUtil.parentPath(path);
+//                location=URIUtil.canonicalPath(URIUtil.addPaths(parent,location));
+//                if (!location.startsWith("/"))
+//                    buf.append('/');
+//                buf.append(location);
+//            }
+            buf.append(location);
+            location=buf.toString();
+        }
+    	
+    	// build redirect location
+    	setHeader("Location",location);
+        setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
     }
+    
+    public StringBuffer getRootURL(URI uri)
+    {
+        StringBuffer url = new StringBuffer();
+        String scheme = uri.getScheme();
+        url.append(scheme);
+        url.append(":");
+    	url.append(uri.getSchemeSpecificPart());
+        return url;
+    }
 
     public void setBufferSize(int size) {
         // TODO Implement buffering, for the moment ignore.
Index: src/main/java/org/apache/cocoon/servletservice/AbsoluteServletConnection.java
===================================================================
--- src/main/java/org/apache/cocoon/servletservice/AbsoluteServletConnection.java	(revision 731081)
+++ src/main/java/org/apache/cocoon/servletservice/AbsoluteServletConnection.java	(working copy)
@@ -77,7 +77,7 @@
             throw iae;
         }
         this.request = new ServletServiceRequest(reqUri, CallFrameHelper.getRequest());
-        this.response = new ServletServiceResponse();
+        this.response = new ServletServiceResponse(this.uri);
     }
 
     /**
Index: src/main/java/org/apache/cocoon/servletservice/ServletConnection.java
===================================================================
--- src/main/java/org/apache/cocoon/servletservice/ServletConnection.java	(revision 731081)
+++ src/main/java/org/apache/cocoon/servletservice/ServletConnection.java	(working copy)
@@ -113,6 +113,12 @@
      * @return a URI representing this servlet connection.
      */
     URI getURI();
+    
+    /**
+    * Get a URI representing the redirect URI incase of responsecode of 302
+    * 
+    * @return a URI representing the redirect servlet connection
+    */
+   URI getRedirectURI();
 
-
 }
Index: src/main/java/org/apache/cocoon/servletservice/util/ServletServiceRequest.java
===================================================================
--- src/main/java/org/apache/cocoon/servletservice/util/ServletServiceRequest.java	(revision 731081)
+++ src/main/java/org/apache/cocoon/servletservice/util/ServletServiceRequest.java	(working copy)
@@ -123,6 +123,8 @@
     private Parameters parameters;
 
     private ServletServiceContext context;
+    
+    private boolean useParentRequest = true;
 
     /**
      * @param uri
@@ -255,18 +257,31 @@
     //
 
     public String getParameter(String name) {
+    	
+    	if (useParentRequest)  			
+    		return (String) this.parentRequest.getParameter(name);
+    	
         return (String) this.parameters.getValue(name);
     }
 
     public String[] getParameterValues(String name) {
+    	if (useParentRequest)
+    		return this.parentRequest.getParameterValues(name);
+    	
         return this.parameters.getValues(name);
     }
 
     public Enumeration getParameterNames() {
+    	if (useParentRequest)
+    		return this.parentRequest.getParameterNames();
+    	
         return this.parameters.getNames();
     }
 
     public Map getParameterMap() {
+    	if (useParentRequest)
+    		return this.parentRequest.getParameterMap();
+    	
         return this.parameters.getValues();
     }
 
Index: src/main/java/org/apache/cocoon/servletservice/AbstractServletConnection.java
===================================================================
--- src/main/java/org/apache/cocoon/servletservice/AbstractServletConnection.java	(revision 731081)
+++ src/main/java/org/apache/cocoon/servletservice/AbstractServletConnection.java	(working copy)
@@ -22,6 +22,7 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.URI;
+import java.net.URISyntaxException;
 
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
@@ -194,5 +195,15 @@
         }
 
     }
+    
+    public URI getRedirectURI() {
+    	String redirectLocation = this.response.getHeader("Location");
+    	try {
+			return new URI(redirectLocation);
+		} catch (URISyntaxException e) {
+			this.logger.error("problems creating correct URI...", e);
+			return null;
+		}
+    }
 
 }
Index: src/main/java/org/apache/cocoon/servletservice/RelativeServletConnection.java
===================================================================
--- src/main/java/org/apache/cocoon/servletservice/RelativeServletConnection.java	(revision 731081)
+++ src/main/java/org/apache/cocoon/servletservice/RelativeServletConnection.java	(working copy)
@@ -79,7 +79,7 @@
 
         // prepare request and response objects
         this.request = new ServletServiceRequest(reqUri, CallFrameHelper.getRequest());
-        this.response = new ServletServiceResponse();
+        this.response = new ServletServiceResponse(reqUri);
 
         if(this.logger.isDebugEnabled()) {
             this.logger.debug("Resolving relative servlet URI " + this.uri.toASCIIString());
