MCPcopy Create free account
hub / github.com/apache/tomcat / toEncoded

Method toEncoded

java/org/apache/catalina/connector/Response.java:1604–1632  ·  view source on GitHub ↗

Return the specified URL with the specified session identifier suitably encoded. @param url URL to be encoded with the session id @param sessionId Session id to be included in the encoded URL @return the encoded URL

(String url, String sessionId)

Source from the content-addressed store, hash-verified

1602 * @return the encoded URL
1603 */
1604 protected String toEncoded(String url, String sessionId) {
1605 if (url == null || sessionId == null) {
1606 return url;
1607 }
1608
1609 String path = url;
1610 String query = "";
1611 String anchor = "";
1612 int question = url.indexOf('?');
1613 if (question >= 0) {
1614 path = url.substring(0, question);
1615 query = url.substring(question);
1616 }
1617 int pound = path.indexOf('#');
1618 if (pound >= 0) {
1619 anchor = path.substring(pound);
1620 path = path.substring(0, pound);
1621 }
1622 StringBuilder sb = new StringBuilder(path);
1623 if (!sb.isEmpty()) { // jsessionid can't be first.
1624 sb.append(';');
1625 sb.append(SessionConfig.getSessionUriParamName(request.getContext()));
1626 sb.append('=');
1627 sb.append(sessionId);
1628 }
1629 sb.append(anchor);
1630 sb.append(query);
1631 return sb.toString();
1632 }
1633}

Callers 2

encodeRedirectURLMethod · 0.95
encodeURLMethod · 0.95

Calls 6

getContextMethod · 0.65
toStringMethod · 0.65
indexOfMethod · 0.45
isEmptyMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected