Hi All,

Prior to Tomcat 7.0.58, we are able to set the context as "/". In the code
it will go to else part and set the context without any issues.

public void setPath(String path) {
        if (path == null || (!path.equals("") && !path.startsWith("/"))) {
            this.path = "/" + path;
            log.warn(sm.getString(
                    "standardContext.pathInvalid", path, this.path));
        } else {
            this.path = path;
        }
        encodedPath = urlEncoder.encode(this.path);
        if (getName() == null) {
            setName(this.path);
        }
    }


But from 7.0.58, when we trying to set context as "/", it will matches
the first of condition as make the path an empty string("").

public void setPath(String path) {
        boolean invalid = false;
        if (path == null || path.equals("/")) {
            invalid = true;
            this.path = "";
        } else if ("".equals(path) || path.startsWith("/")) {
            this.path = path;
        } else {
            invalid = true;
            this.path = "/" + path;
        }
        if (this.path.endsWith("/")) {
            invalid = true;
            this.path = this.path.substring(0, this.path.length() - 1);
        }
        if (invalid) {
            log.warn(sm.getString(
                    "standardContext.pathInvalid", path, this.path));
        }
        encodedPath = urlEncoder.encode(this.path);
        if (getName() == null) {
            setName(this.path);
        }
    }

Is there a any specific reason for this change?
Why it is not allowing to set the context path as "/"

Thanks
Best Regards
/Thusitha


On Thu, Mar 19, 2015 at 4:35 PM, Thusitha Thilina Dayaratne <
thusit...@wso2.com> wrote:

> Hi
>
> Thanks for quick response.
> > Hi,
> >
> > I'm in the process of migrating to a embedded tomcat 7.0.59 application
> to
> > tomcat 8.0.20. In the application i'm setting the context as "*/*" This
> > works fine in tomcat 7
> >
> > But in Tomcat 8 when I set the context as "*/*", internally it is set as
> "".
> >
> > Is this a bug in Tomcat 8?
>
> >>No.
> Why it it is not allowing to set Context as "/" in tomcat 8?
>
> Thanks
> Regards
> /Thusitha
>
>
> On Thu, Mar 19, 2015 at 4:26 PM, Mark Thomas <ma...@apache.org> wrote:
>
>> On 19/03/2015 10:55, Thusitha Thilina Dayaratne wrote:
>> > Hi,
>> >
>> > I'm in the process of migrating to a embedded tomcat 7.0.59 application
>> to
>> > tomcat 8.0.20. In the application i'm setting the context as "*/*" This
>> > works fine in tomcat 7
>> >
>> > But in Tomcat 8 when I set the context as "*/*", internally it is set
>> as "".
>> >
>> > Is this a bug in Tomcat 8?
>>
>> No.
>>
>> Mark
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: dev-h...@tomcat.apache.org
>>
>>
>
>
> --
> Thusitha Dayaratne
> Software Engineer
> WSO2 Inc. - lean . enterprise . middleware |  wso2.com
>
> Mobile  +94712756809
> Blog      alokayasoya.blogspot.com
> About    http://about.me/thusithathilina
>
>


-- 
Thusitha Dayaratne
Software Engineer
WSO2 Inc. - lean . enterprise . middleware |  wso2.com

Mobile  +94712756809
Blog      alokayasoya.blogspot.com
About    http://about.me/thusithathilina

Reply via email to