jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Helen Rehn <hr...@us.ibm.com>
Subject RE: Behavior of getRequestURL in ServletTestCase
Date Wed, 19 Feb 2003 13:30:56 GMT




Hi,

Yes, I had looked at the source code, but the reason for my confusion was
the fact that I had not defined a simulation URL.  Calling
request.getRequestURL() on a servlet or jsp outside of the cactus
environment returns the correct port with no problems, so I'm not sure what
is happening.  I'm just looking for any tips on how I might go about
debugging the problem, because I'm not sure where to look next.

Thanks,
Nell

Nell Rehn
WebSphere Advanced Design and Technology
hrehn@us.ibm.com
(919) 254-1088 t/l 444-1088


                                                                                         
                                        
                      "Vincent Massol"                                                   
                                        
                      <vmassol@octo.com        To:       "'Cactus Users List'" <cactus-user@jakarta.apache.org>
                  
                      >                        cc:       Helen Rehn/Durham/IBM@IBMUS  
                                           
                                               Subject:  RE: Behavior of getRequestURL in
ServletTestCase                         
                      02/19/2003 03:39                                                   
                                        
                      AM                                                                 
                                        
                      Please respond to                                                  
                                        
                      "Cactus Users                                                      
                                        
                      List"                                                              
                                        
                                                                                         
                                        
                                                                                         
                                        




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



---------------------------------------------------------------------
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