// Get the URLRewriter to use to encode session information in the
// URL and use it, do this before stripping the URL as otherwise it is
// not done properly.
MarinerRequestContext requestContext = pageContext.getRequestContext();
URLRewriter sessionURLRewriter = pageContext.getSessionURLRewriter();
MarinerURL sessionURL
= sessionURLRewriter.mapToExternalURL(requestContext,
pageContext.getRequestURL(true));
if (logger.isDebugEnabled()) {
logger.debug("Encoded url is "
+ sessionURL.getExternalForm());
}
// As the link we generate is always back to this page we can reduce the
// overhead by removing the protocol, authority and all but the last part
// of the path. We do this before URL rewriting as we have no idea what
// the URL will look like afterwards.
sessionURL.setProtocol(null);
sessionURL.setAuthority(null);
String path = sessionURL.getPath();
int index = path.lastIndexOf('/');
if (index != -1) {
path = path.substring(index + 1);
sessionURL.setPath(path);
}
if (logger.isDebugEnabled()) {
logger.debug("Relative url is "
+ sessionURL.getExternalForm());
}
// perform any URL rewriting that might be needed
URLRewriter urlRewriter
= pageContext.getVolantisBean().getURLRewriter();
MarinerURL externalURL =
urlRewriter.mapToExternalURL(requestContext, sessionURL);
// Split the URL up
SessionIdentifierSearcher searcher
= SessionIdentifierSearcherFactory.create();
SessionIdentifierURL splitURL
= searcher.getJSessionId(externalURL.getExternalForm());
// If present, add jsessionid to the string table
if (splitURL.hasJsessionid()) {
references.createReference(splitURL.getJsessionid());
if (logger.isDebugEnabled()) {