You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by lr...@apache.org on 2008/02/11 03:06:38 UTC

svn commit: r620376 - /incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java

Author: lresende
Date: Sun Feb 10 18:06:37 2008
New Revision: 620376

URL: http://svn.apache.org/viewvc?rev=620376&view=rev
Log:
Comment code that was failing to retrieve contextPath in certain web containers

Modified:
    incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java

Modified: incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java?rev=620376&r1=620375&r2=620376&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java (original)
+++ incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java Sun Feb 10 18:06:37 2008
@@ -240,7 +240,8 @@
     public void initContextPath(ServletConfig config) {
         ServletContext context = config.getServletContext();
         int version = context.getMajorVersion() * 100 + context.getMinorVersion();
-        if (version >= 205) {
+        //FIXME Do we really need this ? Servlet 2.4 Spec does mention getContextPath
+        //if (version >= 205) {
             // The getContextPath() is introduced since Servlet 2.5
             Method m;
             try {
@@ -254,9 +255,9 @@
                 throw new IllegalStateException(
                                                 "'contextPath' init parameter must be set for pre-2.5 servlet container");
             }
-        } else {
-            contextPath = config.getInitParameter("contextPath");
-        }
+        //} else {
+        //    contextPath = config.getInitParameter("contextPath");
+        //}
         logger.info("initContextPath: " + contextPath);
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Re: svn commit: r620376 - /incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java

Posted by Raymond Feng <en...@gmail.com>.
Hi,

I don't think this is a good fix. The ServletContext.getContextPath() is 
introduced for Servlet Spec 2.5 or later. The major/minor version can tell 
us if the current ServletContext has getContextPath() method. In Servlet 
2.4, the getContextPath() is only available on HttpServletRequest.

With this change, we'll get IllegalStateException for Servlet version before 
2.5. Is the WebSphere Servlet at the level of 2.5 or later? If so, the 
getContextPath() should return a valid value as required by the spec. (See 
[1]). If it returns null, it should be a WebSphere bug :-).

BTW, I don't know why we check the init-parameter for the contextPath as a 
fall-back. Is it a Tuscany specific thing or a Servlet spec statement (I 
couldn't find it in Servlet spec 2.4)?

Thanks,
Raymond

[1] 
http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContext.html#getContextPath()

----- Original Message ----- 
From: <lr...@apache.org>
To: <tu...@ws.apache.org>
Sent: Sunday, February 10, 2008 6:06 PM
Subject: svn commit: r620376 - 
/incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java


> Author: lresende
> Date: Sun Feb 10 18:06:37 2008
> New Revision: 620376
>
> URL: http://svn.apache.org/viewvc?rev=620376&view=rev
> Log:
> Comment code that was failing to retrieve contextPath in certain web 
> containers
>
> Modified:
> 
> incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
>
> Modified: 
> incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
> URL: 
> http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java?rev=620376&r1=620375&r2=620376&view=diff
> ==============================================================================
> ---  
> incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java 
> (original)
> +++ 
> incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java 
> Sun Feb 10 18:06:37 2008
> @@ -240,7 +240,8 @@
>     public void initContextPath(ServletConfig config) {
>         ServletContext context = config.getServletContext();
>         int version = context.getMajorVersion() * 100 + 
> context.getMinorVersion();
> -        if (version >= 205) {
> +        //FIXME Do we really need this ? Servlet 2.4 Spec does mention 
> getContextPath
> +        //if (version >= 205) {
>             // The getContextPath() is introduced since Servlet 2.5
>             Method m;
>             try {
> @@ -254,9 +255,9 @@
>                 throw new IllegalStateException(
>                                                 "'contextPath' init 
> parameter must be set for pre-2.5 servlet container");
>             }
> -        } else {
> -            contextPath = config.getInitParameter("contextPath");
> -        }
> +        //} else {
> +        //    contextPath = config.getInitParameter("contextPath");
> +        //}
>         logger.info("initContextPath: " + contextPath);
>     }
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-commits-help@ws.apache.org
> 


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