1 2 3 27 28 29 package org.apache.coyote.tomcat5; 30 31 32 import java.io.IOException ; 33 import java.io.OutputStream ; 34 import java.io.PrintWriter ; 35 import java.net.MalformedURLException ; 36 import java.security.AccessController ; 37 import java.security.PrivilegedAction ; 38 import java.security.PrivilegedActionException ; 39 import java.security.PrivilegedExceptionAction ; 40 import java.text.SimpleDateFormat ; 41 import java.util.ArrayList ; 42 import java.util.Enumeration ; 43 import java.util.Locale ; 44 import java.util.TimeZone ; 45 import java.util.Vector ; 46 47 import javax.servlet.ServletOutputStream ; 48 import javax.servlet.http.Cookie ; 49 import javax.servlet.http.HttpServletResponse ; 50 51 import org.apache.catalina.Connector; 52 import org.apache.catalina.Context; 53 import org.apache.catalina.Session; 54 import org.apache.catalina.HttpResponse; 55 import org.apache.catalina.Wrapper; 56 import org.apache.catalina.util.CharsetMapper; 57 import org.apache.catalina.util.DateTool; 58 import org.apache.catalina.util.StringManager; 59 import org.apache.catalina.security.SecurityUtil; 60 import org.apache.coyote.Response; 61 import org.apache.tomcat.util.buf.CharChunk; 62 import org.apache.tomcat.util.buf.UEncoder; 63 import org.apache.tomcat.util.http.FastHttpDateFormat; 64 import org.apache.tomcat.util.http.MimeHeaders; 65 import org.apache.tomcat.util.http.ServerCookie; 66 import org.apache.tomcat.util.net.URL; 67 68 import com.sun.appserv.ProxyHandler; 70 72 79 80 public class CoyoteResponse 81 implements HttpResponse, HttpServletResponse { 82 83 84 86 public CoyoteResponse() { 87 outputBuffer = new OutputBuffer(); 89 outputStream = new CoyoteOutputStream(outputBuffer); 90 writer = new CoyoteWriter(outputBuffer); 91 urlEncoder.addSafeCharacter('/'); 93 } 94 95 public CoyoteResponse(boolean chunkingDisabled) { 97 outputBuffer = new OutputBuffer(chunkingDisabled); 98 outputStream = new CoyoteOutputStream(outputBuffer); 99 writer = new CoyoteWriter(outputBuffer); 100 urlEncoder.addSafeCharacter('/'); 101 } 102 104 105 107 108 private String detailErrorMsg; 110 112 113 116 protected SimpleDateFormat format = null; 117 118 119 122 protected static final String info = 123 "org.apache.coyote.tomcat5.CoyoteResponse/1.0"; 124 125 126 129 protected static StringManager sm = 130 StringManager.getManager(Constants.Package); 131 132 133 135 136 139 protected Connector connector; 140 141 144 public Connector getConnector() { 145 return (this.connector); 146 } 147 148 153 public void setConnector(Connector connector) { 154 this.connector = connector; 155 } 156 157 158 161 protected Response coyoteResponse; 162 163 168 public void setCoyoteResponse(Response coyoteResponse) { 169 this.coyoteResponse = coyoteResponse; 170 outputBuffer.setResponse(coyoteResponse); 171 } 172 173 176 public Response getCoyoteResponse() { 177 return (coyoteResponse); 178 } 179 180 181 184 public Context getContext() { 185 return (request.getContext()); 186 } 187 188 196 public void setContext(Context context) { 197 request.setContext(context); 198 } 199 200 201 204 protected OutputBuffer outputBuffer; 207 209 212 215 protected CoyoteOutputStream outputStream; 216 218 221 protected CoyoteWriter writer; 224 226 227 230 protected boolean appCommitted = false; 231 232 233 236 protected boolean included = false; 237 238 239 242 private boolean isCharacterEncodingSet = false; 243 244 247 private boolean isContentTypeSet = false; 248 249 250 253 protected boolean error = false; 254 255 256 259 protected ArrayList cookies = new ArrayList (); 260 261 262 265 protected boolean usingOutputStream = false; 266 267 268 271 protected boolean usingWriter = false; 272 273 274 277 protected UEncoder urlEncoder = new UEncoder(); 278 279 280 283 protected CharChunk redirectURLCC = new CharChunk(); 284 285 286 288 289 293 public void recycle() { 294 295 outputBuffer.recycle(); 296 usingOutputStream = false; 297 usingWriter = false; 298 appCommitted = false; 299 included = false; 300 error = false; 301 isContentTypeSet = false; 302 isCharacterEncodingSet = false; 303 detailErrorMsg = null; 304 305 cookies.clear(); 306 307 if (Constants.SECURITY) { 308 if (facade != null) { 309 facade.clear(); 310 facade = null; 311 } 312 if (outputStream != null) { 313 outputStream.clear(); 314 outputStream = null; 315 } 316 if (writer != null) { 317 writer.clear(); 318 writer = null; 319 } 320 } else { 321 writer.recycle(); 322 } 323 324 } 325 326 327 329 330 333 public int getContentCount() { 334 return outputBuffer.getContentWritten(); 335 } 336 337 338 343 public void setAppCommitted(boolean appCommitted) { 344 this.appCommitted = appCommitted; 345 } 346 347 348 351 public boolean isAppCommitted() { 352 return (this.appCommitted || isCommitted() || isSuspended() 353 || ((getContentLength() > 0) 354 && (getContentCount() >= getContentLength()))); 355 } 356 357 358 361 public boolean getIncluded() { 362 return included; 363 } 364 365 366 372 public void setIncluded(boolean included) { 373 this.included = included; 374 } 375 376 377 382 public String getInfo() { 383 return (info); 384 } 385 386 387 390 protected CoyoteRequest request = null; 391 392 395 public org.apache.catalina.Request getRequest() { 396 return (this.request); 397 } 398 399 404 public void setRequest(org.apache.catalina.Request request) { 405 this.request = (CoyoteRequest) request; 406 } 407 408 409 412 protected CoyoteResponseFacade facade = null; 413 414 418 public HttpServletResponse getResponse() { 419 if (facade == null) { 420 facade = new CoyoteResponseFacade(this); 421 } 422 return (facade); 423 } 424 425 426 429 public OutputStream getStream() { 430 if (outputStream == null) { 431 outputStream = new CoyoteOutputStream(outputBuffer); 432 } 433 return outputStream; 434 } 435 436 437 442 public void setStream(OutputStream stream) { 443 } 445 446 447 452 public void setSuspended(boolean suspended) { 453 outputBuffer.setSuspended(suspended); 454 } 455 456 457 460 public boolean isSuspended() { 461 return outputBuffer.isSuspended(); 462 } 463 464 465 468 public void setError() { 469 error = true; 470 } 471 472 473 476 public boolean isError() { 477 return error; 478 } 479 480 481 487 public void setDetailMessage(String message) { 488 this.detailErrorMsg = message; 489 } 490 491 492 497 public String getDetailMessage() { 498 return this.detailErrorMsg; 499 } 500 502 503 509 public ServletOutputStream createOutputStream() 510 throws IOException { 511 if (outputStream == null) { 513 outputStream = new CoyoteOutputStream(outputBuffer); 514 } 515 return outputStream; 516 } 517 518 519 525 public void finishResponse() 526 throws IOException { 527 try { 529 outputBuffer.close(); 530 } catch(IOException e) { 531 ; 532 } catch(Throwable t) { 533 t.printStackTrace(); 534 } 535 } 536 537 538 541 public int getContentLength() { 542 return (coyoteResponse.getContentLength()); 543 } 544 545 546 550 public String getContentType() { 551 return (coyoteResponse.getContentType()); 552 } 553 554 555 567 public PrintWriter getReporter() throws IOException { 568 if (outputBuffer.isNew()) { 569 outputBuffer.checkConverter(); 570 if (writer == null) { 571 writer = new CoyoteWriter(outputBuffer); 572 } 573 return writer; 574 } else { 575 return null; 576 } 577 } 578 579 580 582 583 588 public void flushBuffer() 589 throws IOException { 590 outputBuffer.flush(); 591 } 592 593 594 597 public int getBufferSize() { 598 return outputBuffer.getBufferSize(); 599 } 600 601 602 605 public String getCharacterEncoding() { 606 return (coyoteResponse.getCharacterEncoding()); 607 } 608 609 610 617 public ServletOutputStream getOutputStream() 618 throws IOException { 619 620 if (usingWriter) 621 throw new IllegalStateException 622 (sm.getString("coyoteResponse.getOutputStream.ise")); 623 624 usingOutputStream = true; 625 if (outputStream == null) { 626 outputStream = new CoyoteOutputStream(outputBuffer); 627 } 628 return outputStream; 629 630 } 631 632 633 636 public Locale getLocale() { 637 return (coyoteResponse.getLocale()); 638 } 639 640 641 648 public PrintWriter getWriter() 649 throws IOException { 650 651 if (usingOutputStream) 652 throw new IllegalStateException 653 (sm.getString("coyoteResponse.getWriter.ise")); 654 655 667 setCharacterEncoding(getCharacterEncoding()); 668 669 usingWriter = true; 670 outputBuffer.checkConverter(); 671 if (writer == null) { 672 writer = new CoyoteWriter(outputBuffer); 673 } 674 return writer; 675 676 } 677 678 679 682 public boolean isCommitted() { 683 return (coyoteResponse.isCommitted()); 684 } 685 686 687 693 public void reset() { 694 695 if (included) 696 return; 698 coyoteResponse.reset(); 699 outputBuffer.reset(); 700 } 701 702 703 709 public void resetBuffer() { 710 711 if (isCommitted()) 712 throw new IllegalStateException 713 (sm.getString("coyoteResponse.resetBuffer.ise")); 714 715 outputBuffer.reset(); 716 717 } 718 719 720 728 public void setBufferSize(int size) { 729 730 if (isCommitted() || !outputBuffer.isNew()) 731 throw new IllegalStateException 732 (sm.getString("coyoteResponse.setBufferSize.ise")); 733 734 outputBuffer.setBufferSize(size); 735 736 } 737 738 739 744 public void setContentLength(int length) { 745 746 if (isCommitted()) 747 return; 748 749 if (included) 751 return; 752 753 if (usingWriter) 754 return; 755 756 coyoteResponse.setContentLength(length); 757 758 } 759 760 761 766 public void setContentType(String type) { 767 768 if (isCommitted()) 769 return; 770 771 if (included) 773 return; 774 775 if (usingWriter) { 777 if (type != null) { 778 int index = type.indexOf(";"); 779 if (index != -1) { 780 type = type.substring(0, index); 781 } 782 } 783 } 784 785 coyoteResponse.setContentType(type); 786 787 if (type != null) { 789 int index = type.indexOf(";"); 790 if (index != -1) { 791 int len = type.length(); 792 index++; 793 while (index < len && Character.isSpace(type.charAt(index))) { 794 index++; 795 } 796 if (index+7 < len 797 && type.charAt(index) == 'c' 798 && type.charAt(index+1) == 'h' 799 && type.charAt(index+2) == 'a' 800 && type.charAt(index+3) == 'r' 801 && type.charAt(index+4) == 's' 802 && type.charAt(index+5) == 'e' 803 && type.charAt(index+6) == 't' 804 && type.charAt(index+7) == '=') { 805 isCharacterEncodingSet = true; 806 } 807 } 808 } 809 810 isContentTypeSet = true; 811 } 812 813 814 821 public void setCharacterEncoding(String charset) { 822 823 if (isCommitted()) 824 return; 825 826 if (included) 828 return; 829 830 if (usingWriter) 833 return; 834 835 coyoteResponse.setCharacterEncoding(charset); 836 isCharacterEncodingSet = true; 837 } 838 839 840 841 847 public void setLocale(Locale locale) { 848 849 if (isCommitted()) 850 return; 851 852 if (included) 854 return; 855 856 coyoteResponse.setLocale(locale); 857 858 if (usingWriter) 861 return; 862 863 if (isCharacterEncodingSet) { 864 return; 865 } 866 867 CharsetMapper cm = getContext().getCharsetMapper(); 868 String charset = cm.getCharset( locale ); 869 if ( charset != null ){ 870 coyoteResponse.setCharacterEncoding(charset); 871 } 872 873 } 874 875 876 878 879 883 public Cookie [] getCookies() { 884 return ((Cookie []) cookies.toArray(new Cookie [cookies.size()])); 885 } 886 887 888 896 public String getHeader(String name) { 897 return coyoteResponse.getMimeHeaders().getHeader(name); 898 } 899 900 901 905 public String [] getHeaderNames() { 906 907 MimeHeaders headers = coyoteResponse.getMimeHeaders(); 908 int n = headers.size(); 909 String [] result = new String [n]; 910 for (int i = 0; i < n; i++) { 911 result[i] = headers.getName(i).toString(); 912 } 913 return result; 914 915 } 916 917 918 925 public String [] getHeaderValues(String name) { 926 927 Enumeration e = coyoteResponse.getMimeHeaders().values(name); 928 Vector result = new Vector (); 929 while (e.hasMoreElements()) { 930 result.addElement(e.nextElement()); 931 } 932 String [] resultArray = new String [result.size()]; 933 result.copyInto(resultArray); 934 return resultArray; 935 936 } 937 938 939 943 public String getMessage() { 944 return coyoteResponse.getMessage(); 945 } 946 947 948 951 public int getStatus() { 952 return coyoteResponse.getStatus(); 953 } 954 955 956 963 public void reset(int status, String message) { 964 reset(); 965 setStatus(status, message); 966 } 967 968 969 971 972 978 public void addCookie(final Cookie cookie) { 979 980 if (isCommitted()) 981 return; 982 983 if (included) 985 return; 986 987 cookies.add(cookie); 988 989 final StringBuffer sb = new StringBuffer (); 990 if (SecurityUtil.isPackageProtectionEnabled()) { 991 AccessController.doPrivileged(new PrivilegedAction () { 992 public Object run(){ 993 ServerCookie.appendCookieValue 994 (sb, cookie.getVersion(), cookie.getName(), 995 cookie.getValue(), cookie.getPath(), 996 cookie.getDomain(), cookie.getComment(), 997 cookie.getMaxAge(), cookie.getSecure()); 998 return null; 999 } 1000 }); 1001 } else { 1002 ServerCookie.appendCookieValue 1003 (sb, cookie.getVersion(), cookie.getName(), cookie.getValue(), 1004 cookie.getPath(), cookie.getDomain(), cookie.getComment(), 1005 cookie.getMaxAge(), cookie.getSecure()); 1006 } 1007 1008 addHeader("Set-Cookie", sb.toString()); 1012 1013 } 1014 1015 1016 1022 public void addDateHeader(String name, long value) { 1023 1024 if (isCommitted()) 1025 return; 1026 1027 if (included) { 1029 return; 1030 } 1031 1032 if (format == null) { 1033 format = new SimpleDateFormat (DateTool.HTTP_RESPONSE_DATE_HEADER, 1034 Locale.US); 1035 format.setTimeZone(TimeZone.getTimeZone("GMT")); 1036 } 1037 1038 addHeader(name, FastHttpDateFormat.formatDate(value, format)); 1039 1040 } 1041 1042 1043 1049 public void addHeader(String name, String value) { 1050 1051 if (isCommitted()) 1052 return; 1053 1054 if (included) 1056 return; 1057 1058 coyoteResponse.addHeader(name, value); 1059 1060 } 1061 1062 1063 1069 public void addIntHeader(String name, int value) { 1070 1071 if (isCommitted()) 1072 return; 1073 1074 if (included) 1076 return; 1077 1078 addHeader(name, "" + value); 1079 1080 } 1081 1082 1083 1088 public boolean containsHeader(String name) { 1089 return coyoteResponse.containsHeader(name); 1090 } 1091 1092 1093 1099 public String encodeRedirectURL(String url) { 1100 1101 if (isEncodeable(toAbsolute(url))) { 1102 return (toEncoded(url, request.getSessionInternal().getIdInternal())); 1103 } else { 1104 return (url); 1105 } 1106 1107 } 1108 1109 1110 1119 public String encodeRedirectUrl(String url) { 1120 return (encodeRedirectURL(url)); 1121 } 1122 1123 1124 1130 public String encodeURL(String url) { 1131 1132 String absolute = toAbsolute(url); 1133 if (isEncodeable(absolute)) { 1134 if (url.equalsIgnoreCase("")){ 1136 url = absolute; 1137 } 1138 return (toEncoded(url, request.getSessionInternal().getIdInternal())); 1139 } else { 1140 return (url); 1141 } 1142 1143 } 1144 1145 1146 1155 public String encodeUrl(String url) { 1156 return (encodeURL(url)); 1157 } 1158 1159 1160 1165 public void sendAcknowledgement() 1166 throws IOException { 1167 1168 if (isCommitted()) 1169 return; 1170 1171 if (included) 1173 return; 1174 1175 coyoteResponse.acknowledge(); 1176 1177 } 1178 1179 1180 1190 public void sendError(int status) 1191 throws IOException { 1192 sendError(status, null); 1193 } 1194 1195 1196 1206 public void sendError(int status, String message) 1207 throws IOException { 1208 1209 if (isCommitted()) 1210 throw new IllegalStateException 1211 (sm.getString("coyoteResponse.sendError.ise")); 1212 1213 if (included) 1215 return; 1216 1217 Wrapper wrapper = getRequest().getWrapper(); 1218 if (wrapper != null) { 1219 wrapper.incrementErrorCount(); 1220 } 1221 1222 setError(); 1223 1224 coyoteResponse.setStatus(status); 1225 coyoteResponse.setMessage(message); 1226 1227 resetBuffer(); 1229 1230 setSuspended(true); 1232 1233 } 1234 1235 1236 1245 public void sendRedirect(String location) 1246 throws IOException { 1247 1248 if (isCommitted()) 1249 throw new IllegalStateException 1250 (sm.getString("coyoteResponse.sendRedirect.ise")); 1251 1252 if (included) 1254 return; 1255 1256 resetBuffer(); 1258 1259 try { 1261 1264 String absolute; 1266 if (getContext().getAllowRelativeRedirect()) 1267 absolute = location; 1268 else 1269 absolute = toAbsolute(location); 1270 setStatus(SC_FOUND); 1272 setHeader("Location", absolute); 1273 } catch (IllegalArgumentException e) { 1274 setStatus(SC_NOT_FOUND); 1275 } 1276 1277 setSuspended(true); 1279 1280 } 1281 1282 1283 1289 public void setDateHeader(String name, long value) { 1290 1291 if (isCommitted()) 1292 return; 1293 1294 if (included) { 1296 return; 1297 } 1298 1299 if (format == null) { 1300 format = new SimpleDateFormat (DateTool.HTTP_RESPONSE_DATE_HEADER, 1301 Locale.US); 1302 format.setTimeZone(TimeZone.getTimeZone("GMT")); 1303 } 1304 1305 setHeader(name, FastHttpDateFormat.formatDate(value, format)); 1306 1307 } 1308 1309 1310 1316 public void setHeader(String name, String value) { 1317 1318 if (isCommitted()) 1319 return; 1320 1321 if (included) 1323 return; 1324 1325 coyoteResponse.setHeader(name, value); 1326 1327 } 1328 1329 1330 1336 public void setIntHeader(String name, int value) { 1337 1338 if (isCommitted()) 1339 return; 1340 1341 if (included) 1343 return; 1344 1345 setHeader(name, "" + value); 1346 1347 } 1348 1349 1350 1355 public void setStatus(int status) { 1356 setStatus(status, null); 1357 } 1358 1359 1360 1370 public void setStatus(int status, String message) { 1371 1372 if (isCommitted()) 1373 return; 1374 1375 if (included) 1377 return; 1378 1379 coyoteResponse.setStatus(status); 1380 coyoteResponse.setMessage(message); 1381 1382 } 1383 1384 1385 1387 1388 1401 protected boolean isEncodeable(final String location) { 1402 1403 if (location == null) 1404 return (false); 1405 1406 if (location.startsWith("#")) 1408 return (false); 1409 1410 final CoyoteRequest hreq = request; 1412 final Session session = hreq.getSessionInternal(false); 1413 if (session == null) 1414 return (false); 1415 if (hreq.isRequestedSessionIdFromCookie()) 1416 return (false); 1417 1418 if (SecurityUtil.isPackageProtectionEnabled()) { 1419 return ((Boolean ) 1420 AccessController.doPrivileged(new PrivilegedAction () { 1421 1422 public Object run(){ 1423 return new Boolean (doIsEncodeable(hreq, session, location)); 1424 } 1425 })).booleanValue(); 1426 } else { 1427 return doIsEncodeable(hreq, session, location); 1428 } 1429 } 1430 1431 private boolean doIsEncodeable(CoyoteRequest hreq, Session session, 1432 String location){ 1433 URL url = null; 1435 try { 1436 url = new URL(location); 1437 } catch (MalformedURLException e) { 1438 return (false); 1439 } 1440 1441 if (!hreq.getScheme().equalsIgnoreCase(url.getProtocol())) 1443 return (false); 1444 if (!hreq.getServerName().equalsIgnoreCase(url.getHost())) 1445 return (false); 1446 int serverPort = hreq.getServerPort(); 1447 if (serverPort == -1) { 1448 if ("https".equals(hreq.getScheme())) 1449 serverPort = 443; 1450 else 1451 serverPort = 80; 1452 } 1453 int urlPort = url.getPort(); 1454 if (urlPort == -1) { 1455 if ("https".equals(url.getProtocol())) 1456 urlPort = 443; 1457 else 1458 urlPort = 80; 1459 } 1460 if (serverPort != urlPort) 1461 return (false); 1462 1463 String contextPath = getContext().getPath(); 1464 if ( contextPath != null ) { 1465 String file = url.getFile(); 1466 if ((file == null) || !file.startsWith(contextPath)) 1467 return (false); 1468 if( file.indexOf(";jsessionid=" + session.getIdInternal()) >= 0 ) 1469 return (false); 1470 } 1471 1472 return (true); 1474 1475 } 1476 1477 1478 1488 protected String toAbsolute(String location) { 1489 1490 if (location == null) 1491 return (location); 1492 1493 boolean leadingSlash = location.startsWith("/"); 1494 1495 if (leadingSlash 1496 || (!leadingSlash && (location.indexOf("://") == -1))) { 1497 1498 redirectURLCC.recycle(); 1499 1500 String scheme = request.getScheme(); 1501 1502 if (getConnector() != null 1504 && getConnector().getAuthPassthroughEnabled()) { 1505 ProxyHandler proxyHandler = getConnector().getProxyHandler(); 1506 if (proxyHandler != null 1507 && proxyHandler.getSSLKeysize(request) > 0) { 1508 scheme = "https"; 1509 } 1510 } 1511 1513 String name = request.getServerName(); 1514 int port = request.getServerPort(); 1515 1516 try { 1517 redirectURLCC.append(scheme, 0, scheme.length()); 1518 redirectURLCC.append("://", 0, 3); 1519 redirectURLCC.append(name, 0, name.length()); 1520 if ((scheme.equals("http") && port != 80) 1521 || (scheme.equals("https") && port != 443)) { 1522 redirectURLCC.append(':'); 1523 String portS = port + ""; 1524 redirectURLCC.append(portS, 0, portS.length()); 1525 } 1526 if (!leadingSlash) { 1527 String relativePath = request.getDecodedRequestURI(); 1528 int pos = relativePath.lastIndexOf('/'); 1529 relativePath = relativePath.substring(0, pos); 1530 1531 String encodedURI = null; 1532 final String frelativePath = relativePath; 1533 1534 if (SecurityUtil.isPackageProtectionEnabled() ){ 1535 try{ 1536 encodedURI = (String )AccessController.doPrivileged( 1537 new PrivilegedExceptionAction (){ 1538 public Object run() throws IOException { 1539 return urlEncoder.encodeURL(frelativePath); 1540 } 1541 }); 1542 } catch (PrivilegedActionException pae){ 1543 IllegalArgumentException iae = 1544 new IllegalArgumentException (location); 1545 iae.initCause(pae.getCause()); 1546 throw iae; 1547 } 1548 } else { 1549 encodedURI = urlEncoder.encodeURL(relativePath); 1550 } 1551 1552 redirectURLCC.append(encodedURI, 0, encodedURI.length()); 1553 redirectURLCC.append('/'); 1554 } 1555 redirectURLCC.append(location, 0, location.length()); 1556 } catch (IOException e) { 1557 IllegalArgumentException iae = 1558 new IllegalArgumentException (location); 1559 iae.initCause(e); 1560 throw iae; 1561 } 1562 1563 return redirectURLCC.toString(); 1564 1565 } else { 1566 1567 return (location); 1568 1569 } 1570 1571 } 1572 1573 1574 1581 protected String toEncoded(String url, String sessionId) { 1582 1583 if ((url == null) || (sessionId == null)) 1584 return (url); 1585 1586 String path = url; 1587 String query = ""; 1588 String anchor = ""; 1589 int question = url.indexOf('?'); 1590 if (question >= 0) { 1591 path = url.substring(0, question); 1592 query = url.substring(question); 1593 } 1594 int pound = path.indexOf('#'); 1595 if (pound >= 0) { 1596 anchor = path.substring(pound); 1597 path = path.substring(0, pound); 1598 } 1599 StringBuffer sb = new StringBuffer (path); 1600 if( sb.length() > 0 ) { sb.append(";jsessionid="); 1602 sb.append(sessionId); 1603 } 1604 1605 String jrouteId = request.getHeader(Constants.PROXY_JROUTE); 1607 if (jrouteId != null) { 1608 sb.append(":"); 1609 sb.append(jrouteId); 1610 } 1611 1613 sb.append(anchor); 1614 sb.append(query); 1615 return (sb.toString()); 1616 1617 } 1618 1619 1620} 1621 1622 | Popular Tags |