JSF State Saving initially to server & on session timeout transfer to client?
Asked Answered
H

1

5

Are there any state saving method that would allow JSF application to intially save state data on server but after the session expire time interval , that state is transferred to client so that app is always responsive even after the session timeout on the server & memory is better managed on server?

Or any way this could be implemented? But I expect that this should be a part of the JSF specification !


Edit

After suggestion by BalusC, I'm highly impressed with the Stateless JSF principles & the current implementation for it. If anyone else here is also interested in stateless JSF being added to the JSF spec, consider having a look at or voting this issue.

Stateless JSF offers huge performance boosts for some payoffs like inability to create views dynamically (e.g. by binding, JSTL tags, etc), or modifying it.


A Stateless JSF operation mode would be incredibly useful for high-load applications and architectures:

https://web.archive.org/web/20140626062226/http://industrieit.com/blog/2011/11/stateless-jsf-high-performance-zero-per-request-memory-overhead/#comment-4

This has previously been suggested by Jacob: http://weblogs.java.net/blog/jhook/archive/2006/01/experiment_goin.html

This would help JSF ditch the stigma of "slow and memory hog," and help keep up with current tech trends (stateless architectures.)

Hus answered 30/4, 2012 at 14:25 Comment(1)
Voted on the issue. Stateless JSF is actually too nice as removes the performance penalties of stateful JSF.Egocentrism
C
5

How is that technically possible? The server can never reliably predict beforehand if the next request would create a new session and thus the response of the current request has to use client side state saving instead of server side state saving. If you ever succeed to implement it using plain JSP/Servlet, feel free to post a JSF specification enhancement request.

Just use client side state saving and make sure that partial state saving is enabled. The overhead is relatively minor as compared to full state saving.

Note that it's possible to use JSF entirely stateless. See also this blog. The only major payoff is that you can't create views dynamically (e.g. by binding, JSTL tags, etc), nor manipulate it after creation (e.g. by adding/removing component's children).

See also:

Chau answered 30/4, 2012 at 18:35 Comment(7)
Thanks for introducing me to stateless JSF ! Probably this is going to be nicer for me since I'm (perhaps)not dynamically creating/ modifying any views as you described. But I guess this is a work under very initial stages of development, right ? So it is safe to use right now ? Perhaps worth a try anyway..Hus
It's still in beta. I have never tried it by the way. In theory it's good possible and the payoff of inability to dynamically create/manipulate views is fully understandable, that's exactly what JSF needs to save the state for.Chau
Yes, worth a try. But I doubt if any considerable no of people are using this in production environment! I shall try testing this sooner in case it's easier to switch.Hus
@user01 did you ever succeeded in testing it?Hochheimer
@MikeBraun: yep, I did & it works superb(great improvement in performance) with Mojarra impl. except there were some minor things that did not worked. Btw before using in production, I'm waiting for this to be officially included in the JSF spec and provided as a part of Mojarra or Myfaces.Hus
The blog entry is gone, see the archive.org version.Rox
@Pixelstix: Since 2013 you can natively turn on stateless JSF by <f:view transient="true">. See also a.o. stackoverflow.com/questions/14890995/…Chau

© 2022 - 2024 — McMap. All rights reserved.