Dai
Dai

Reputation: 11

How to display cookie value in JSF facelet (xhtml file) by using implicit object; "cookie"

I wrote a code as follows in JSF facelet(xhtml file)

   ${cookie}

If I run the xhtml file on a web app server. The below is displayed on the screen.

   {JSESSIONID=javax.servlet.http.Cookie@faf91d8} 

However, it seems to be the address of where the cookie instance is stored. I want to see the value(sessionid) in the cookie. I tried this code, but it did not work.

   ${cookie[value]}

I tried reading the following specifications in JCP, but I could not find the answer.

   https://jcp.org/en/jsr/detail?id=372

Could you please tell me how to properly write a code to display a value in a cookie? I would appreciate your help.

Upvotes: 1

Views: 811

Answers (1)

Kukeltje
Kukeltje

Reputation: 12337

As you can see from what is printed, it looks like a key-value pair and since the spec says it maps to a single cookie,

#{cookie['JSESSIONID']}

is what returns an actual single cookie. But you still need the value of it so

#{cookie['JSESSIONID'].value}

is most likely what you need

See also

Upvotes: 2

Related Questions