tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mario Gliewe" <mgli...@leveld.de>
Subject PATCH: url-rewriting for sessionids
Date Wed, 08 Dec 1999 17:34:36 GMT
hi,

here's a patch to support encodeUrl() and accept session-ids via url;
i'm not sure how to decide whether or not to add the session on
encodeRedirectURL(), so its ommited; any suggestions?

boolean isRequestedSessionIdFromUrl() is not supported, but could
easyly be added.


src/share/org/apache/tomkat/core/ServerSessionManager.java:
line 129:
//[---- [12-08-99 maG] support session ids via uri
 if (request==null)
  System.out.println("request is null?!?");
 else
 if (session==null) {
  String
sessionIds[]=request.getParameterValues(Constants.Cookie.SESSION_COOKIE_NAME
);
  for (int n=0;sessionIds!=null && session==null && n<sessionIds.length;
n++) {
   session=(ServerSession)sessions.get(sessionIds[n]);
   if (session!=null) {
    sessionId=sessionIds[n];
    // not quite sure: should we really add a cookie???
    Cookie cookie=new Cookie(Constants.Cookie.SESSION_COOKIE_NAME,
sessionId);
    response.addCookie(cookie);
   }
  }
 }
// ----]

src/share/org/apache/tomkat/core/HttpServletResponseFacade.java:
line 127:
public String encodeURL(String url) {
    // XXX
    // we don't support url rewriting yet!
    //[---- [12-08-99 maG] support url-rewriting for session-tracking

  if (url==null)
   return url;

  ApplicationSession session=response.request.getSession(false);
  if (session==null) {
   return url;
  }

  // got valid session; append to url
  String cookie=Constants.Cookie.SESSION_COOKIE_NAME+"="+session.getId();
  if (url.indexOf("?")>0) {
   return url+"&"+cookie;
  } else {
   return url+"?"+cookie;
  }
  //----]

--
% ar m God
ar: God does not exist


Mime
View raw message