You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Thusitha Thilina Dayaratne <th...@wso2.com> on 2015/03/19 11:55:32 UTC

Can't set context to "/" in Tomcat 8.0.20

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?

Thanks
Best Regards
/Thusitha
-- 
Thusitha Dayaratne
Software Engineer
WSO2 Inc. - lean . enterprise . middleware |  wso2.com

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

Re: Can't set context to "/" in Tomcat 8.0.20

Posted by Mark Thomas <ma...@apache.org>.
Do NOT cross-post questions to the users list and the dev list. All this
does is annoy the very people you are relying on to take time out of
whatever else they are doing to help you.

If you aren't sure where to ask, user the users list.

On 19/03/2015 11:50, Thusitha Thilina Dayaratne wrote:
> Hi All,
> 
> Prior to Tomcat 7.0.58, we are able to set the context as "/".

There are lots of things you can set configuration values to and Tomcat
will still start. That doesn't mean that they are sensible settings or
even valid ones. While Tomcat will usually catch obviously broken
settings, users are expected to RTFM before they start changing things.

"/" has never been a valid value for the context path as has been made
clear in the Servlet specification and the Tomcat docs for as long as I
can remember (10+ years).

<snip/>

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

There is no change. That has never been valid. That it worked in some
subset of previous Tomcat versions is nothing more than luck.

Mark


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


Re: Can't set context to "/" in Tomcat 8.0.20

Posted by Mark Thomas <ma...@apache.org>.
Do NOT cross-post questions to the users list and the dev list. All this
does is annoy the very people you are relying on to take time out of
whatever else they are doing to help you.

If you aren't sure where to ask, user the users list.

On 19/03/2015 11:50, Thusitha Thilina Dayaratne wrote:
> Hi All,
> 
> Prior to Tomcat 7.0.58, we are able to set the context as "/".

There are lots of things you can set configuration values to and Tomcat
will still start. That doesn't mean that they are sensible settings or
even valid ones. While Tomcat will usually catch obviously broken
settings, users are expected to RTFM before they start changing things.

"/" has never been a valid value for the context path as has been made
clear in the Servlet specification and the Tomcat docs for as long as I
can remember (10+ years).

<snip/>

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

There is no change. That has never been valid. That it worked in some
subset of previous Tomcat versions is nothing more than luck.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Can't set context to "/" in Tomcat 8.0.20

Posted by Thusitha Thilina Dayaratne <th...@wso2.com>.
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 <
thusithad@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-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: dev-help@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

Re: Can't set context to "/" in Tomcat 8.0.20

Posted by Thusitha Thilina Dayaratne <th...@wso2.com>.
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 <
thusithad@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-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: dev-help@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

Re: Can't set context to "/" in Tomcat 8.0.20

Posted by Thusitha Thilina Dayaratne <th...@wso2.com>.
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-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@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

Re: Can't set context to "/" in Tomcat 8.0.20

Posted by Mark Thomas <ma...@apache.org>.
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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org