How to retrieve session values as a val or var and use it in gatling users session

Hi,

I have to confess that I am very new to Gatling and Scala but really interested to learn both to create a performance testing frame work.

My question is, Is there anyway I can retrieve a session (from java HTTP session) value as a val or var and use it in my EL(gatling users session)?

For example

pseudo code

val some_token_str = session(“some_token”).as[String]

then

.headers(headers_2)
.body(StringBody(session =>
s"""{“someKey”:“GAT${some_token_str}”,“name”:“Gatling${some_token_str}”,“someid”:“4bca2bae-76f9-461b-adc3-e0ecec07d90f”,“context”:{“name”:“Gatling”,“someKey”:“GAT${some_token_str}”}} “”")).asJSON,
http(“request_35”)
.get("/display/GAT${some_token_str}")
.headers(headers_0),
http(“request_36”)

The current working one is:

s"""{“someKey”:“GAT${session(“some_token”).as[String]}”,“name”:“Gatling${session(“some_token”).as[String]}”,“someid”:“4bca2bae-76f9-461b-adc3-e0ecec07d90f”,“context”:{“name”:“Gatling”,“someKey”:“GAT${session(“some_token”).as[String]}”}} “”")).asJSON,

Repeating the string casting every time I use that token is too much waste of resources.

Thanks
Manoj