1.

What is the importance of session scope?

Answer»

Session scopes are used to create BEAN INSTANCES for HTTP sessions. This would mean that a single bean can be used for serving multiple HTTP REQUESTS. The scope of the bean can be defined by means of using scope attribute or using @Scope or @SessionScope annotations.

  • Using scope attribute:
<bean id="userBean" CLASS="com.interviewbit.UserBean" scope="session"/>
  • Using @Scope annotation:
@Component@Scope("session")public class UserBean { //some methods and properties}
  • Using @SessionScope:
@Component@SessionScopepublic class UserBean { //some methods and properties}


Discussion

No Comment Found