DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22309>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22309

org.struts.bean.IncludeTag extending for sticky cluster node

           Summary: org.struts.bean.IncludeTag extending for sticky cluster
                    node
           Product: Struts
           Version: 1.1RC2
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Custom Tags
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


The include tag has the following inside the doStartTag method:

            if ((conn instanceof HttpURLConnection)
                && urlString.startsWith(request.getContextPath())
                && (request.getRequestedSessionId() != null)
                && request.isRequestedSessionIdFromCookie()) {
                StringBuffer sb = new StringBuffer("JSESSIONID=");
                sb.append(request.getRequestedSessionId());
                conn.setRequestProperty("Cookie", sb.toString());
            }

I would like to request that this is moved to a protected method to allow for it
to be overriden.

    protected void setCookie(URLConnection conn, HttpServletRequest request,
String urlString, URL url)  {
        
        if ((conn instanceof HttpURLConnection) && 
        urlString.startsWith(request.getContextPath()) && 
        (request.getRequestedSessionId() != null) && 
        request.isRequestedSessionIdFromCookie()) {
        
            StringBuffer sb = new StringBuffer("JSESSIONID=");
            sb.append(request.getRequestedSessionId());
            conn.setRequestProperty("Cookie", sb.toString());
        }

    }

The reason I need to overload this method when extending this class is to
support a cluster.  The problem with the include tag in a cluster is as follows:

Client - ip=10.10.10.1 - requests to LoadBalancer, LB sends request for
10.10.10.1 to Node A, Node A - ip=10.10.10.2 - then uses the include tag for a
request, request goes out to LB - since include tag uses host of incoming
request -, LB says 10.2 is a new client and sends request to Node B.  

The hardware loadbalancer that I use will actually just stop at this point
instead of sending the request on to Node B, not sure why.  In any case the
requests should be sticky and say on the same node so what I did is I extended
the include tag and I have some logic that detects if I am running in a cluster
mode and if so I grab the ip address of the current node and use the setHref
method.  

This works for the most part except that the logic used to check if a JSESSION
should be appended onto the http request fails since the url doesn't startWith
/application it now startsWith http://ipaddress/application.   The way I'd like
to solve this is to overload the setCookie method and instead of using the
urlString I use the URL and check the URL's contextPath against the startsWith.
 So my overloaded method looks like:

    protected void setCookie(URLConnection conn, HttpServletRequest request,
String urlString, URL url)  {
        if ((conn instanceof HttpURLConnection) && 
                url.getPath().startsWith(request.getContextPath()) && 
                (request.getRequestedSessionId() != null) && 
                request.isRequestedSessionIdFromCookie()) {
            StringBuffer sb = new StringBuffer("JSESSIONID=");
            sb.append(request.getRequestedSessionId());
            conn.setRequestProperty("Cookie", sb.toString());
        }

    }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to