Commits

Anonymous committed f6588fb

Fixed WW-713: The <ww:url> tag does not correctly construct the URL when the scheme attribute is set and the scheme changes.

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@672573baa09-0c28-0410-bef9-dab3c582ae83

  • Participants
  • Parent commits 8e38301

Comments (0)

Files changed (1)

File src/java/com/opensymphony/webwork/views/util/UrlHelper.java

-/*
- * Copyright (c) 2002-2003 by OpenSymphony
- * All rights reserved.
- */
 package com.opensymphony.webwork.views.util;
 
 import com.opensymphony.webwork.ServletActionContext;
 public class UrlHelper {
     //~ Static fields/initializers /////////////////////////////////////////////
 
+    /** Default HTTP port (80). */
+    private static final int DEFAULT_HTTP_PORT = 80;
+
+    /** Default HTTPS port (443). */
+    private static final int DEFAULT_HTTPS_PORT = 443;
+
     private static final String AMP = "&";
 
     //~ Methods ////////////////////////////////////////////////////////////////
 
         boolean changedScheme = false;
 
-        int httpPort = 80;
+        int httpPort = DEFAULT_HTTP_PORT;
 
         try {
             httpPort = Integer.parseInt((String) Configuration.get("webwork.url.http.port"));
         } catch (Exception ex) {
         }
 
-        int httpsPort = 443;
+        int httpsPort = DEFAULT_HTTPS_PORT;
 
         try {
             httpsPort = Integer.parseInt((String) Configuration.get("webwork.url.https.port"));
             link.append("://");
             link.append(request.getServerName());
 
-            // do not append port for default ports
-            int port = request.getServerPort();
-
-            if (!(scheme.equals("http") && (port == httpPort)) && !(scheme.equals("https") && (port == httpsPort))) {
+            if ((scheme.equals("http") && (httpPort != DEFAULT_HTTP_PORT)) || (scheme.equals("https") && httpsPort != DEFAULT_HTTPS_PORT)) {
                 link.append(":");
-                link.append(port);
+                link.append(scheme.equals("http") ? httpPort : httpsPort);
             }
         }