portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wea...@apache.org
Subject svn commit: r328889 - /portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
Date Thu, 27 Oct 2005 15:01:32 GMT
Author: weaver
Date: Thu Oct 27 08:01:28 2005
New Revision: 328889

URL: http://svn.apache.org/viewcvs?rev=328889&view=rev
Log:
displayPortletNotAvailableMessage() did not take into account the fact that 
response.getWriter() may fail if response.getOutputStream() had been called 
prior to it being invoked.

Modified:
    portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java

Modified: portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java?rev=328889&r1=328888&r2=328889&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
(original)
+++ portals/jetspeed-2/trunk/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
Thu Oct 27 08:01:28 2005
@@ -17,6 +17,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.Timer;
@@ -221,14 +222,7 @@
                 // inject the current request into the renderRequest handler (o.a.j.engine.servlet.ServletRequestImpl)
                 ((HttpServletRequestWrapper)((HttpServletRequestWrapper)renderRequest).getRequest()).setRequest(request);
 
-                if (null == portlet)
-                {
-                    throw new Exception("Content is not available.");
-                }
-                else
-                {
-                    portlet.render(renderRequest, renderResponse);
-                }
+                portlet.render(renderRequest, renderResponse);
             }
 
             // if we get this far we are home free
@@ -276,8 +270,17 @@
     private void displayPortletNotAvailableMessage(Throwable t, HttpServletResponse response,
String portletName)
     throws IOException
     {
-        getServletContext().log(JCS + "Error rendering JetspeedContainerServlet error page:
" + t.toString(), t);                
-        PrintWriter directError = new PrintWriter(response.getWriter());
+        getServletContext().log(JCS + "Error rendering JetspeedContainerServlet error page:
" + t.toString(), t);
+        PrintWriter directError;
+        try
+        {
+            directError = new PrintWriter(response.getWriter());
+        }
+        catch (IllegalStateException e)
+        {
+            // Happens if get writer is already been called.
+            directError = new PrintWriter(new OutputStreamWriter(response.getOutputStream()));
           
+        }
         directError.write("Portlet is Not Available: " + portletName + "<br/>Reason:
" + t.getMessage());
         //t.printStackTrace(directError); 
         directError.close();        



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message