1

I have one web page in this i have one variable like state and it set value like state , I want this value if i refresh my page then also i want to get value without using of session ,

I try the page scope but it can not give value if i refresh the page,it will return null.

I set value like this...

String name="Hello";  
pageContext.setAttribute("user",name); 

I get value like this

String name1=(String)pageContext.getAttribute("user"); 

I don't want to use session in this.

Vijay
  • 8,131
  • 11
  • 43
  • 69
Panchotiya Vipul
  • 1,226
  • 5
  • 17
  • 42

1 Answers1

0

IMO, you should go with an option of storing your user values in a Cookie. I mean, storing a user name in a cookie wont occupy much space it would be in Bytes and wont hurt your performance too.

You can refer to following post for how to write and read a cookie in JSF. In addition to this, you can handle the cookie contents the way you want to. Just delete the cookies when the "user" gets into your scope.

How to use cookies in JSF

Community
  • 1
  • 1
Vinayak Pingale
  • 1,315
  • 8
  • 19