era
era

Reputation: 481

Pass expired session variable value in to a subsequent request

I have a JSf application and users call that application from an another site (assume test.com ). When calling the my app from test.com it send me a get parameter and based on that I decide which style sheet need to apply.

Example call : myapp.com?style=aaa

Based on style parameter I am applying a style sheet for myapp. In here I am find the style sheet from style parameter value and keep it in a session for use in other pages.

Problem :

When tomcat session expire I am loose the my style information and my site goes to a default style sheet (user press browser reload button or submit a form after session expiration). How I can still keep style sheet information even after session expiration.

I can not have a style information as an application level parameter since it's change based on test.com calls.

thanks

Upvotes: 0

Views: 591

Answers (2)

BalusC
BalusC

Reputation: 1108722

One user may have many logins in myapp.com. There fore multiple calls can come from single browser like myapp.com?style=aaa , myapp.com?style=bbb. So using cookies may difficult.

You would need to keep passing the style around as request parameter by adding it as <f:param> to all forms and links in all your JSF pages.

E.g.

<h:link value="link" outcome="nextpage">
    <f:param name="style" value="#{param.style}" />
</h:link>

and

<h:commandButton value="submit" action="#{someBean.someAction}">
    <f:param name="style" value="#{param.style}" />
</h:commandButton>      

Upvotes: 0

reevesy
reevesy

Reputation: 3472

If you just want to remember the stylesheet it would probably be better to write the stylesheet parameter to a cookie instead of the HttpSession. This way when the session has expired and the user returns they will still see the stylesheet they have choosen.

However, If they delete their cookies or your cookies expires then they will get the default stylesheet.

A Quick google came up with this cookie example http://gthill.blogspot.com/2008/01/cookies-in-jsf.html

Upvotes: 1

Related Questions