Hi Zafer,
Does the app include the jsession ID in the URI already? If so, it would be much, much simpler to persist off of that than try to generate your own session ID in a rule, insert it in every URI path in response headers and content and then parse and remove it in requests. You could try the first option using a codeshare example and/or a similar post:
Provides persistence on the JSessionID value found in either the URI or a cookie.
http://devcentral.f5.com/wiki/default.aspx/iRules/Weblogic_JSessionID_Persistence.html
URI Session ID based persistence issue
http://devcentral.f5.com/Default.aspx?tabid=53&forumid=5&tpage=1&view=topic&postid=1564715891
If you really want to try the second option, you'd need to collect response content, identify all non-third party URL references, generate a token based on the selected pool member, insert the token into the paths, and in subsequent requests parse this session id, remove it and select the pool member if it was up. It's possible, but it would not be a trivial job...
Aaron