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.)

stiemannkj1
  • 4,418
  • 3
  • 25
  • 45
Rajat Gupta
  • 25,853
  • 63
  • 179
  • 294
  • 2
    Voted on the issue. Stateless JSF is actually too nice as removes the performance penalties of stateful JSF. – Aklin May 01 '12 at 03:03

1 Answers1

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:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • 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.. – Rajat Gupta Apr 30 '12 at 19:02
  • 1
    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. – BalusC Apr 30 '12 at 19:04
  • 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. – Rajat Gupta Apr 30 '12 at 19:10
  • @user01 did you ever succeeded in testing it? – Mike Braun Dec 28 '12 at 20:46
  • 1
    @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. – Rajat Gupta Dec 30 '12 at 14:04
  • The blog entry is gone, see the [archive.org version](http://web.archive.org/web/20120605163546/http://industrieit.com:80/blog/2011/11/stateless-jsf-high-performance-zero-per-request-memory-overhead/). – Pixelstix Jun 15 '17 at 16:00
  • @Pixelstix: Since 2013 you can natively turn on stateless JSF by ``. See also a.o. https://stackoverflow.com/questions/14890995/what-is-the-usefulness-of-statelessness-in-jsf – BalusC Jun 15 '17 at 17:36