Forum Discussion
JRahm
Apr 27, 2005Admin
I'd start here from another post:
rule WeblogicJSessionPersist {
when CLIENT_ACCEPTED {
set add_persist 1
}
when HTTP_RESPONSE {
if { [HTTP::cookie exists "JSESSIONID"] and $add_persist } {
persist add uie [HTTP::cookie "JSESSIONID"]
set add_persist 0
}
}
when HTTP_REQUEST {
if { [HTTP::cookie exists "JSESSIONID"] } {
persist uie [HTTP::cookie "JSESSIONID"]
} else {
set jsess [findstr [HTTP::uri] "jsessionid" 11 ";"]
if { $jsess != "" } {
persist uie $jsess
}
}
}
}
What you're trying to do is pull out the server names from the cookie. I'm not really familiar with all the fields, but our version looks like this:
JSESSIONID=!!!!!!!;
I'm not schooled enough with tcl to instruct you on pulling out the strings between the 2nd and 3rd ! terminator and the 5th and 6th ! terminator and pushing them into variables. You might want to build a class to match your server names as seen in the cookie to IP's so you'll have them available to persist correctly. That would look something like:
when rule_init {
array set ::server_definitions {
server1_name 10.1.1.1
server2_name 10.1.1.2
}
}
Then in the HTTP_REQUEST event, you could set variables with the primary and secondary servers from the cookie, get the actual IPs, then use that to persist, primary in the if statement and secondary in the elseif, else if nothing matches.
I wish I had the coding experience to help you, I like to participate in the creation of rules, though, it helps me get better.