1 package org.apache.turbine; 2 3 56 57 import javax.servlet.http.HttpServletRequest ; 58 import org.apache.turbine.RunData; 59 60 83 public class RelativeDynamicURI 84 extends DynamicURI 85 { 86 90 public RelativeDynamicURI() 91 { 92 } 93 94 99 public RelativeDynamicURI( RunData data ) 100 { 101 super(data); 102 } 103 104 110 public RelativeDynamicURI( RunData data, 111 boolean redirect ) 112 { 113 super(data, redirect); 114 } 115 116 134 public String toString() 135 { 136 StringBuffer output = new StringBuffer (128); 137 output.append ( getScriptName() ); 138 if ( this.hasPathInfo() ) 139 { 140 output.append ( "/" ); 141 renderPathInfo(this.pathInfo, output); 142 } 143 if ( this.hasQueryData() ) 144 { 145 output.append ( "?" ); 146 renderQueryString(this.queryData, output); 147 } 148 149 if ( this.res != null ) 153 { 154 if ( this.redirect ) 155 { 156 return res.encodeRedirectURL (output.toString()); 157 } 158 else 159 { 160 return res.encodeURL (output.toString()); 161 } 162 } 163 else 164 { 165 return output.toString(); 166 } 167 } 168 169 179 public static String toString(RunData data) 180 { 181 StringBuffer output = new StringBuffer (128); 182 HttpServletRequest request = data.getRequest(); 183 184 output.append ( data.getScriptName() ); 185 186 if ( request.getPathInfo() != null ) 187 { 188 output.append( request.getPathInfo() ); 189 } 190 191 if ( request.getQueryString() != null ) 192 { 193 output.append ( "?" ); 194 output.append ( request.getQueryString() ); 195 } 196 return output.toString(); 197 } 198 } 199 200 201 | Popular Tags |