Forum Discussion

Julian_Annison_'s avatar
Julian_Annison_
Icon for Nimbostratus rankNimbostratus
Apr 29, 2005

SAP persistence using jsessionid

Below is an explanation(give to me be a SAP consultant) of what happens when a user logs into a SAP portal the jsessionid that we would like to persist on can be in the url or a cookie is there a simple way to search for the jsessionid value between the brackets and persit on it this value can be a variable length an anywhere in the url.

 

We are trying to use an F5 to replace a SAP web dispatcher if anyone is familiar with that product.

 

 

I have tried one of the WEBlogic iRules which seemed to need the sme kind of rule but it didn't work.

 

 

Any help would be greatly appreciated

 

 

Thanks

 

 

Julian

 

 

 

1) A user logs on to the Portal and gains the following cookies of relevance to us here

 

 

•Set-Cookie: sapj2ee_*=942620174; Version=1; Path=/

 

•Set-Cookie: JSESSIONID=(UKLONSAP003_QP7_00)ID942620174DB0.4130594099718703End; Version=1; Domain=.uk.mycompany.com; Path=/irj/

 

•Set-Cookie: MYSAPSSO2=AjExMDAgABFwb3J0YWw6dWtzYXB1YXQyN4gAB2RlZmF1bHQBAApVS1NBUFVBVDI3AgADMDAwAwADUVA3BAAMMjAwNTAyMjUwODMxBQAEAAAACAoAClVLU0FQVUFUMjf%2FAVAwggFMBgkqhkiG9w0BBwKgggE9MIIBOQIBATELMAkGBSsOAwIaBQAwCwYJKoZIhvcNAQcBMYIBGDCCARQCAQEwajBlMQswCQYDVQQGEwJERTEcMBoGA1UEChMTU0FQIFRydXN0IENvbW11bml0eTERMA8GA1UECxMIRGVsb2l0dGUxFzAVBgNVBAsTDnBvcnRhbHBsYXRmb3JtMQwwCgYDVQQDEwNRUDcCAQAwCQYFKw4DAhoFAKBdMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTA1MDIyNTA4MzE0MlowIwYJKoZIhvcNAQkEMRYEFByYNdK9jHboiGic5kXS11t%2F7rR%2BMAkGByqGSM44BAMELjAsAhQtlcohNAZjI%2B2wpLy6zJUX9murkAIUc8U4feJspD5ECYrHBWNRXyqVWdI%3D; HttpOnly; Domain=uk.mycompany.com; Path=/

 

 

 

The JSESSIONID cookie has a path attribute so that calls to other non Portal J2EE's will not use this cookie.

 

The MYSAPSSO2 cookie will be used everywhere so does not have a path

 

The sapj2ee cookie is not used by the Webdynpro J2EE's as they are a newer release and so does not need a path.

 

 

2) A call is made to project management on the J2EE with the MYSAPSSO2 cookie and the following are set

 

 

•set-cookie: saplb_*=(J2EE808190400)808190450; Version=1; Path=/webdynpro/dispatcher/

 

•set-cookie: JSESSIONID=(J2EE808190400)ID808190450DB1218742496146419353End; Version=1; Path=/webdynpro/dispatcher/

 

 

Both of these cookies are set with a path attribute to ensure they are only passed with Webdynpro calls.

 

 

3) The user click on part of project management which produces a Webdynpro get to obtain information on the PDF

 

4) On the J2EE 640 server the project management application acts as a client and sends a request to run a non Webdynpro application with POST /sapphirej2ee/upload

 

5) The sapphirej2ee application returns the session information about its location back to the project management application in the form of a URL like as follows

 

 

•/sapphirej2ee/output;jsessionid=(J2EE813210800)ID813210850DB1218862027862180632End;saplb_*=(J2EE813210800)813210850

 

 

This example shows the sapphirej2ee application can be running on a different server.

 

 

6) The Webdynpro project management application sends this response back to the client who in turn then issues a GET for the information

 

 

•GET /sapphirej2ee/output;jsessionid=(J2EE813210800)ID813210850DB1218862027862180632End;saplb_*=(J2EE813210800)813210850 HTTP/1.1

 

•Cookie: MYSAPSSO2=AjExMDAgABFwb3J0YWw6dWtzYXB1YXQyN4gAB2RlZmF1bHQBAApVS1NBUFVBVDI3AgADMDAwAwADUVA3BAAMMjAwNTAyMjUwODMxBQAEAAAACAoAClVLU0FQVUFUMjf%2FAVAwggFMBgkqhkiG9w0BBwKgggE9MIIBOQIBATELMAkGBSsOAwIaBQAwCwYJKoZIhvcNAQcBMYIBGDCCARQCAQEwajBlMQswCQYDVQQGEwJERTEcMBoGA1UEChMTU0FQIFRydXN0IENvbW11bml0eTERMA8GA1UECxMIRGVsb2l0dGUxFzAVBgNVBAsTDnBvcnRhbHBsYXRmb3JtMQwwCgYDVQQDEwNRUDcCAQAwCQYFKw4DAhoFAKBdMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTA1MDIyNTA4MzE0MlowIwYJKoZIhvcNAQkEMRYEFByYNdK9jHboiGic5kXS11t%2F7rR%2BMAkGByqGSM44BAMELjAsAhQtlcohNAZjI%2B2wpLy6zJUX9murkAIUc8U4feJspD5ECYrHBWNRXyqVWdI%3D; SAPWP_active=1; DSMKeepAliveStamp=1109320311571

 

 

 

We are having problems with the F5 in production and I suspect this is down to the fact that the GET /sapphirej2ee statement issued by the client is being routed to the server where the Webdynpro application is running.

 

We need the F5 to identify the correct server from the URL. The gobbledegook jsessionid can be related to the server that can be obtained by the F5 frequently retrieving load balancing information from the Java engine message server

 

5 Replies

  • Does the bracket always immediately follow the JSESSIONID= ? If so, this should work:

     

     

    set jsess_contents [ findstr [HTTP::uri] "JSESSIONID" 12 ")"]

     

     

     

    Check this post for handling the persistence, it should take care of your needs:

     

     

    http://devcentral.f5.com/default.aspx?tabid=28&view=topic&forumid=5&postid=2111

     

     

  • Thanks for the reply

     

     

    Yee the jsessionid string is always in the format

     

    jsessionid=(J2EE813210800)weather it be cookie or url

     

     

    i previosly did see the post you suggested and tried it out but when adding it via the GUI had problems with syntax errors.

     

     

    I will try it again with your modified line of code

     

     

    Thanks

     

     

    Julian
  • I tried a modified version of the rules on the link you provided but no joy.

     

     

    I am now looking at a slightly different approach.

     

    In the below rule i am trying to check the URI response from a server and if it includes a jsessionid make a note of it and add it to the persistence table. This would then be checked again when a the next request was made.

     

    I am not by any means a programmer ( just the odd bash scripts every now and then) so would appreciate any help on this.

     

    The rule is currently not working and the log has the following error

     

     

    May 26 10:05:09 tmm tmm[693]: 01220001:3: TCL error: Rule sapphire_persist - Illegal argument. Invalid server side API (line 1) invoked from within "HTTP::uri"

     

     

    The GUI shows no errors when adding the rule

     

     

     

    when HTTP_RESPONSE {

     

    if { [findstr [HTTP::uri] "jsessionid"] } {

     

    set jsess1 [findstr [HTTP::uri] "jsessionid" 13 ")"]

     

    log local0. "jsessionid found, jsess is: $jsess1"

     

    persist add uie $jsess1

     

    }

     

    }

     

    when HTTP_REQUEST {

     

    set jsess [findstr [HTTP::uri] "jsessionid" 13 ")"]

     

    log local0. "Entering REQUEST, jsess is: $jsess"

     

    if { $jsess != "" } {

     

    persist uie $jsess

     

    }

     

    }

     

     

    Thanks

     

     

    Julian
  • bl0ndie_127134's avatar
    bl0ndie_127134
    Historic F5 Account
    Julian, HTTP::uri command can only be executed from client side events and HTTP_RESPONSE doesn't happen to be one of them. Looks like the validation check did not detect this and I will open a CR48746 to ensure that this gets caught in the future. In the mean time, I have included a modified version of the rule that should get you up and running.

    when HTTP_REQUEST { 
       set uri [HTTP::uri] 
       set jsess [findstr $uri "jsessionid" 13 ")"] 
       log local0. "Entering REQUEST, jsess is: $jsess" 
       if { $jsess != "" } { 
         persist uie $jsess 
       } 
     } 
      
     when HTTP_RESPONSE { 
       if { [findstr $uri "jsessionid"] } { 
         set jsess1 [findstr $uri "jsessionid" 13 ")"] 
         log local0. "jsessionid found, jsess is: $jsess1" 
         persist add uie $jsess1 
       } 
     }

  • Thanks for the response.

     

     

    I kind of worked out not long after i posted, that what i was asking in the HTTP response was not valid but i didn't know enough about it to quote the correct function/method

     

     

    Thanks again

     

     

    i'll let you know how it goes :-)

     

     

     

    Julian