DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=28222>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=28222





------- Additional Comments From [EMAIL PROTECTED]  2006-09-22 15:54 -------
For those of you affected by this bug, here is a simple utility method for
recreating the URL of the current request:

/** 
 * Recreates the full URL that originally got the web client to the given 
 * request.  This takes into account changes to the request due to request 
 * dispatching.
 *
 * <p>Note that if the protocol is HTTP and the port number is 80 or if the
 * protocol is HTTPS and the port number is 443, then the port number is not 
 * added to the return string as a convenience.</p>
 */
public final static String getReturnURL(HttpServletRequest request)
{
    if (request == null)
    {
        throw new IllegalArgumentException("Cannot take null parameters.");
    }
    
    String scheme = request.getScheme();
    String serverName = request.getServerName();
    int serverPort = request.getServerPort();
    
    //try to get the forwarder value first, only if it's empty fall back to the
current value
    String requestUri =
(String)request.getAttribute("javax.servlet.forward.request_uri");
    requestUri = (requestUri == null) ? request.getRequestURI() : requestUri;
 
    //try to get the forwarder value first, only if it's empty fall back to the
current value 
    String queryString =
(String)request.getAttribute("javax.servlet.forward.query_string");
    queryString = (queryString == null) ? request.getQueryString() : qs;

    StringBuffer buffer = new StringBuffer();
    buffer.append(scheme);
    buffer.append("://");
    buffer.append(serverName);
    
    //if not http:80 or https:443, then add the port number
    if(
        !(scheme.equalsIgnoreCase("http") && serverPort == 80) &&
        !(scheme.equalsIgnoreCase("https") && serverPort == 443)
    )
    {
        buffer.append(String.valueOf(serverPort));
    }
    
    buffer.append(requestUri);
    
    if (queryString != null)
    {
        buffer.append("?");
        buffer.append(queryString);
    }
    
    return buffer.toString();
}


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to