jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Massol" <vmas...@octo.com>
Subject RE: Behavior of getRequestURL in ServletTestCase
Date Wed, 19 Feb 2003 08:39:51 GMT
Hi Helen,

If you have defined a simulation URL by calling WebRequest.setURL() in
your beginXXX() method, then getRequestURL() will return the values you
have set there. Otherwise, it will return the real request URL.

Here's the source code:

    public StringBuffer getRequestURL()
    {
        StringBuffer result;

        if (this.url != null)
        {
            result = new StringBuffer(this.url.getProtocol() + "://"
                + getServerName() + ":" + getServerPort() +
getContextPath() 
                + getServletPath() + getPathInfo());
        }
        else
        {
            result = this.request.getRequestURL();
        }

        return result;
    }

where this.url is the simulated URL (null if none has been defined) and
where this.request is the original HttpServletRequest (FYI, Cactus is
wrapping HttpServletRequest in order to correctly return values in
accordance with the simulated URL when defined).

Hope this helps,
-Vincent

> -----Original Message-----
> From: Helen Rehn [mailto:hrehn@us.ibm.com]
> Sent: 17 February 2003 19:59
> To: cactus-user@jakarta.apache.org
> Subject: Behavior of getRequestURL in ServletTestCase
> 
> 
> 
> 
> 
> Hi,
> 
> I'm confused about the behavior of getRequestURL in ServletTestCase.
I'm
> using Cactus 1.4 and WebSphere.  I've extended ServletTestCase, and in
one
> of my test methods, I call:
> 
> ((HttpServletRequest) request).getRequestURL().toString()
> 
> My webapp is running on port 8082, which is what is specified in
> cactus.properties but instead I get the following output:
> http://localhost:80/testnullnull
> 
> Why is the port not what I expect?
> 
> Thanks,
> Nell
> 
> Nell Rehn
> WebSphere Advanced Design and Technology
> hrehn@us.ibm.com
> (919) 254-1088 t/l 444-1088
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org



Mime
View raw message