You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Melissa Matthews <me...@cendex.com> on 2001/02/13 01:07:53 UTC

Problem with request.getServerName in redirect

I am using Apache/Tomcat 3.2.1.  When I use request.getServerName to build
the page for the redirect, the http:// is included in the server name.
Why is this?

This is the code I'm using:

StringBuffer loginpoint = new StringBuffer();

loginpoint.append(request.getScheme())
              .append("://")
              .append(request.getServerName())
               .append(request.getRequestURI());


The problem is I end up with http://http://.....

Any suggestions?




Re: Problem with request.getServerName in redirect

Posted by John Golubenko <go...@columbiafunds.com>.
Well,
Because request.getRequestURI() returns full URI.
This will work:

StringBuffer loginpoint = new StringBuffer();
loginpoing.append(request.getScheme())
	.append("://")
	.append(request.getServerName())
	.append("/mypage.jsp");

Or better use request.getRequestURI(), it will have
the URL value.
- John.

>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<

On 2/12/01, 4:07:53 PM, "Melissa Matthews" <me...@cendex.com> wrote 
regarding Problem with request.getServerName in redirect:


> I am using Apache/Tomcat 3.2.1.  When I use request.getServerName to 
build
> the page for the redirect, the http:// is included in the server name.
> Why is this?

> This is the code I'm using:

> StringBuffer loginpoint = new StringBuffer();

> loginpoint.append(request.getScheme())
>               .append("://")
>               .append(request.getServerName())
>                .append(request.getRequestURI());


> The problem is I end up with http://http://.....

> Any suggestions?




> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-user-help@jakarta.apache.org

NOTICE:  This communication may contain confidential or other privileged information.  If you are not the intended recipient, or believe that you have received this communication in error, please do not print, copy, retransmit, disseminate, or otherwise use the information.  Also, please indicate to the sender that you have received this email in error, and delete the copy you received.  Any communication that does not relate to official Columbia business is that of the sender and is neither given nor endorsed by Columbia.  Thank you.



RE: Problem with request.getServerName in redirect

Posted by Marc Saegesser <ma...@apropos.com>.
Melissa,

As Craig said, please submit a bug report about this.  I'd also appreciate
it if you could try accessing the SnoopServlet that ships with Tomcat and
see if the server name that it reports includes the scheme.  That way we'll
have a known test case to validate against.

Also include the details of your configuration.  I just ran SnoopServlet
under Tomcat 3.2.1 and 3.2.2-dev using the standalone server and behind IIS
and the results look OK.  If you are seeing something different then the
problem must be in the connector.  The more information you can give us the
better.

Thanks,
Marc Saegesser

> -----Original Message-----
> From: Craig R. McClanahan [mailto:Craig.McClanahan@eng.sun.com]
> Sent: Monday, February 12, 2001 6:23 PM
> To: tomcat-user@jakarta.apache.org
> Subject: Re: Problem with request.getServerName in redirect
>
>
> Melissa Matthews wrote:
>
> > I am using Apache/Tomcat 3.2.1.  When I use
> request.getServerName to build
> > the page for the redirect, the http:// is included in the server name.
> > Why is this?
> >
> > This is the code I'm using:
> >
> > StringBuffer loginpoint = new StringBuffer();
> >
> > loginpoint.append(request.getScheme())
> >               .append("://")
> >               .append(request.getServerName())
> >                .append(request.getRequestURI());
> >
> > The problem is I end up with http://http://.....
> >
>
> Sounds like a bug in 3.2.1.
>
> >
> > Any suggestions?
> >
>
> Could you please report this to the bug tracking system at:
>
>     http://nagoya.apache.org/bugzilla/
>
> under product "Tomcat 3"?  We are working on a 3.2.2 update, and
> it would be
> useful to get this bug fixed in time to make that release.
>
> Craig McClanahan
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-user-help@jakarta.apache.org


Re: Problem with request.getServerName in redirect

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Melissa Matthews wrote:

> I am using Apache/Tomcat 3.2.1.  When I use request.getServerName to build
> the page for the redirect, the http:// is included in the server name.
> Why is this?
>
> This is the code I'm using:
>
> StringBuffer loginpoint = new StringBuffer();
>
> loginpoint.append(request.getScheme())
>               .append("://")
>               .append(request.getServerName())
>                .append(request.getRequestURI());
>
> The problem is I end up with http://http://.....
>

Sounds like a bug in 3.2.1.

>
> Any suggestions?
>

Could you please report this to the bug tracking system at:

    http://nagoya.apache.org/bugzilla/

under product "Tomcat 3"?  We are working on a 3.2.2 update, and it would be
useful to get this bug fixed in time to make that release.

Craig McClanahan