Commits

plightbo  committed 77227a4
  • Participants
  • Parent commits 1189d22

Comments (0)

Files changed (3)

File src/etc/taglib.tld

             <required>false</required>
             <rtexprvalue>true</rtexprvalue>
         </attribute>
+        <attribute>
+            <name>includeContext</name>
+            <required>false</required>
+            <rtexprvalue>false</rtexprvalue>
+        </attribute>
+        <attribute>
+            <name>encode</name>
+            <required>false</required>
+            <rtexprvalue>false</rtexprvalue>
+        </attribute>
     </tag>
 
     <tag>

File src/java/com/opensymphony/webwork/views/jsp/URLTag.java

     // Attributes ----------------------------------------------------
     protected String valueAttr;
     protected String scheme = "http";
+    protected boolean includeContext = true;
+    protected boolean encodeResult = true;
 
     //~ Methods ////////////////////////////////////////////////////////////////
 
         scheme = aScheme;
     }
 
+    public void setIncludeContext(boolean includeContext) {
+        this.includeContext = includeContext;
+    }
+
+    public void setEncodeResult(boolean encodeResult) {
+        this.encodeResult = encodeResult;
+    }
+
     public int doEndTag() throws JspException {
         HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
         HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
-        String result = UrlHelper.buildUrl(value, request, response, params, scheme);
+        String result = UrlHelper.buildUrl(value, request, response, params, scheme, includeContext, encodeResult);
 
         String id = getId();
 

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

     private static final String AMP = "&";
 
     public static String buildUrl(String action, HttpServletRequest request, HttpServletResponse response, Map params) {
-        return buildUrl(action, request, response, params, null);
+        return buildUrl(action, request, response, params, null, true, true);
     }
 
-    public static String buildUrl(String action, HttpServletRequest request, HttpServletResponse response, Map params, String scheme) {
+    public static String buildUrl(String action, HttpServletRequest request, HttpServletResponse response,
+                                  Map params, String scheme, boolean includeContext, boolean encodeResult) {
         StringBuffer link = new StringBuffer();
 
          boolean changedScheme = false;
         if (action != null) {
             // Check if context path needs to be added
             // Add path to absolute links
-            if (action.startsWith("/")) {
+            if (action.startsWith("/") && includeContext) {
                 link.append(request.getContextPath());
             }
             else if (changedScheme) {
         String result;
 
         try {
-            result = response.encodeURL(link.toString());
+            result = encodeResult ? response.encodeURL(link.toString()) : link.toString();
         } catch (Exception ex) {
             // Could not encode the URL for some reason
             // Use it unchanged