You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-commits@incubator.apache.org by aw...@apache.org on 2006/10/06 16:30:26 UTC

svn commit: r453662 - /incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/DispatchServletResponse.java

Author: awiner
Date: Fri Oct  6 09:30:25 2006
New Revision: 453662

URL: http://svn.apache.org/viewvc?view=rev&rev=453662
Log:
ADFFACES-217: NPE if ServletResponse.setContentTpe(null) is called.  Patch from Venkata Guddanti

Modified:
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/DispatchServletResponse.java

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/DispatchServletResponse.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/DispatchServletResponse.java?view=diff&rev=453662&r1=453661&r2=453662
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/DispatchServletResponse.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/webapp/DispatchServletResponse.java Fri Oct  6 09:30:25 2006
@@ -39,30 +39,32 @@
   public void setContentType(
     String contentTypeAndCharset)
   {
-    Matcher matcher = _CONTENT_TYPE_PATTERN.matcher(contentTypeAndCharset);
-    if (matcher.matches())
+    if(contentTypeAndCharset != null)
     {
-      String contentType = matcher.group(1);
-      String charset = (matcher.groupCount() > 1) ? matcher.group(2) : null; 
-      
-      // capture the content type on the request
-      _request.setAttribute(_CONTENT_TYPE_KEY, contentType);
-
-      // TODO: use Agent APIs when available
-      if ("application/xhtml+xml".equals(contentType))
+      Matcher matcher = _CONTENT_TYPE_PATTERN.matcher(contentTypeAndCharset);
+      if (matcher.matches())
       {
-        String userAgent = _request.getHeader("User-agent");
-        if (userAgent.indexOf("compatible; MSIE") != -1)
+        String contentType = matcher.group(1);
+        String charset = (matcher.groupCount() > 1) ? matcher.group(2) : null; 
+        
+        // capture the content type on the request
+        _request.setAttribute(_CONTENT_TYPE_KEY, contentType);
+  
+        // TODO: use Agent APIs when available
+        if ("application/xhtml+xml".equals(contentType))
         {
-          // IE must serve XHTML as text/html
-          contentTypeAndCharset = "text/html";
-
-          if (charset != null)
-            contentTypeAndCharset += ";charset=" + charset;
+          String userAgent = _request.getHeader("User-agent");
+          if (userAgent.indexOf("compatible; MSIE") != -1)
+          {
+            // IE must serve XHTML as text/html
+            contentTypeAndCharset = "text/html";
+  
+            if (charset != null)
+              contentTypeAndCharset += ";charset=" + charset;
+          }
         }
       }
     }
-
     super.setContentType(contentTypeAndCharset);
   }