2

Possible Duplicate:
Basic steps for starting session in jsf

Is there any Tag in JSF through we can create session and mantain it.I have seen the wonderful answers by BalusC regarding sessions in JAVA.But can I do all this using a simple JSF tag? Or i have to put all the stuff in backing bean?

Community
  • 1
  • 1
  • It look like that you're also looking in the wrong direction for the solution. You do not need to create/manage "the session" yourself at all. The container does it already for you. You just have to declare a session scoped managed bean and/or store/retrieve attributes in/from the session. Basically, your question is already answered by the link which you found yourself. – BalusC Jan 05 '13 at 11:55

1 Answers1

1

The only reason I can think of why you would want to do this is so you could bind input data to the session without needing to create a managed bean. This is possible.

This input field value binds to the foo property on the session:

<h:inputText value='#{sessionScope.foo}' />

But this is a false economy. If you want to act on this data you will likely need to inject it into a bean so your business logic can make use of it. Nothing is gained.

McDowell
  • 107,573
  • 31
  • 204
  • 267
  • I dont want anything like that.. I want that if the user is authenticated his name should be present in the session... –  Jan 05 '13 at 09:15
  • Ah, you mean authenticating a user with the application somehow. There are many mechanisms available at both the container and application level. You would need to state which approach you are using - for example, the [Java EE 6 tutorial discusses a few of security options](http://docs.oracle.com/javaee/6/tutorial/doc/bncat.html) available though its list is not exhaustive. – McDowell Jan 05 '13 at 10:10