There are probably better ways, but I've used the following java code for
that purpose.

  public static String getFullURL(HttpServletRequest request) {
    if (request==null) return null;
    StringBuffer url = new StringBuffer();
    url.append( (request.isSecure() ? "https://"; : "http://";) );
    url.append(request.getServerName());
    if (request.getServerPort()!=80) url.append(":" +
request.getServerPort());
    url.append(request.getRequestURI());
    if (request.getQueryString()!=null &&
request.getQueryString().trim().length()>0)
url.append("?"+request.getQueryString());
    return url.toString();
  }

Regards,
John

[EMAIL PROTECTED]
Ph (09) 372-5010


|---------+------------------------------->
|         |           "Toby Saville"      |
|         |           <[EMAIL PROTECTED]|
|         |           nsw.gov.au>         |
|         |                               |
|         |           20/08/2004 03:46 PM |
|         |           Please respond to   |
|         |           "Struts Users       |
|         |           Mailing List"       |
|         |                               |
|---------+------------------------------->
  
>--------------------------------------------------------------------------------------------------------------|
  |                                                                                    
                          |
  |       To:       <[EMAIL PROTECTED]>                                                
                     |
  |       cc:                                                                          
                          |
  |       Subject:  Absolute URLs                                                      
                          |
  
>--------------------------------------------------------------------------------------------------------------|




Is there any way I can make URL's generated by struts, be absolute
including the protocol, hostname and port?

Thanks


***************************************************************
This message is intended for the addressee named and
may  contain confidential information. If you are not the
intended recipient, please delete it and notify the sender.
Views expressed in this message are those of the
individual sender, and are not necessarily the views of
the Department of  Lands.

This email message has been swept by MIMEsweeper
for the presence of computer viruses.
***************************************************************




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

Reply via email to