craigmcc    01/03/10 16:58:47

  Modified:    src/doc  release-notes-1.0-b2.xml
               src/share/org/apache/struts/taglib/html BaseTag.java
               src/share/org/apache/struts/util RequestUtils.java
  Log:
  Correct hyperlinks generated by <html:link> and <html:redirect> to
  properly omit the port number if it is the default for this scheme (80 for
  http, 443 for https).
  
  PR: Bugzilla #918
  Submitted by: <[EMAIL PROTECTED]>
  
  Revision  Changes    Path
  1.6       +5 -0      jakarta-struts/src/doc/release-notes-1.0-b2.xml
  
  Index: release-notes-1.0-b2.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/doc/release-notes-1.0-b2.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- release-notes-1.0-b2.xml  2001/03/10 23:55:36     1.5
  +++ release-notes-1.0-b2.xml  2001/03/11 00:58:41     1.6
  @@ -88,6 +88,11 @@
           server if this checkbox is checked at submit time.  In addition, a
           default value of <code>on</code> is sent if no value attribute is
           specified.</li>
  +    <li>The hyperlinks created by the <code>&lt;html:link&gt;</code> and
  +        <code>&lt;html:redirect&gt;</code> tags now properly omit the port
  +        number if it is the default port for the current request scheme (80
  +        for http, or 443 for https).  Among other things, this corrects
  +        session management behavior on the standard port numbers.</li>
       </ul>
   
       <p>The following changes and bug fixes to the Struts Documentation
  
  
  
  1.4       +8 -6      
jakarta-struts/src/share/org/apache/struts/taglib/html/BaseTag.java
  
  Index: BaseTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/BaseTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BaseTag.java      2001/03/06 22:06:05     1.3
  +++ BaseTag.java      2001/03/11 00:58:43     1.4
  @@ -1,13 +1,13 @@
   /*
  - * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/BaseTag.java,v 1.3 
2001/03/06 22:06:05 craigmcc Exp $
  - * $Revision: 1.3 $
  - * $Date: 2001/03/06 22:06:05 $
  + * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/BaseTag.java,v 1.4 
2001/03/11 00:58:43 craigmcc Exp $
  + * $Revision: 1.4 $
  + * $Date: 2001/03/11 00:58:43 $
    *
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -29,7 +29,7 @@
    *    Alternately, this acknowlegement may appear in the software itself,
    *    if and wherever such third-party acknowlegements normally appear.
    *
  - * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
  + * 4. The names "The Jakarta Project", "Struts", and "Apache Software
    *    Foundation" must not be used to endorse or promote products derived
    *    from this software without prior written permission. For written
    *    permission, please contact [EMAIL PROTECTED]
  @@ -69,7 +69,9 @@
   import javax.servlet.jsp.tagext.TagSupport;
   import org.apache.struts.action.Action;
   import org.apache.struts.util.MessageResources;
  +import org.apache.struts.util.RequestUtils;
   
  +
   /**
    * Renders an HTML <base> element with an href 
    * attribute pointing to the absolute location of the enclosing JSP page. This 
  @@ -80,7 +82,7 @@
    * this tag.
    *
    * @author Luis Arias <[EMAIL PROTECTED]>
  - * @version $Revision: 1.3 $ $Date: 2001/03/06 22:06:05 $
  + * @version $Revision: 1.4 $ $Date: 2001/03/11 00:58:43 $
    */
   
   public class BaseTag extends TagSupport {
  
  
  
  1.8       +15 -8     
jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java
  
  Index: RequestUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- RequestUtils.java 2001/02/23 18:42:25     1.7
  +++ RequestUtils.java 2001/03/11 00:58:45     1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java,v 1.7 
2001/02/23 18:42:25 craigmcc Exp $
  - * $Revision: 1.7 $
  - * $Date: 2001/02/23 18:42:25 $
  + * $Header: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java,v 1.8 
2001/03/11 00:58:45 craigmcc Exp $
  + * $Revision: 1.8 $
  + * $Date: 2001/03/11 00:58:45 $
    *
    * ====================================================================
    *
  @@ -89,7 +89,7 @@
    * in the Struts controller framework.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.7 $ $Date: 2001/02/23 18:42:25 $
  + * @version $Revision: 1.8 $ $Date: 2001/03/11 00:58:45 $
    */
   
   public class RequestUtils {
  @@ -126,11 +126,18 @@
        */
       public static String absoluteURL(HttpServletRequest request, String path) {
   
  +        URL url = null;
  +        int port = request.getServerPort();
  +        String scheme = request.getScheme();
  +        String serverName = request.getServerName();
  +        String uri = request.getContextPath() + path;
           try {
  -            URL url = new URL(request.getScheme(),
  -                              request.getServerName(),
  -                              request.getServerPort(),
  -                              request.getContextPath() + path);
  +            if ("http".equals(scheme) && (80 == port))
  +                url = new URL(scheme, serverName, uri);
  +            else if ("https".equals(scheme) && (443 == port))
  +                url = new URL(scheme, serverName, uri);
  +            else
  +                url = new URL(scheme, serverName, port, uri);
               return (url.toString());
           } catch (MalformedURLException e) {
               return (null);
  
  
  

Reply via email to