Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8066191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:54:19+00:00 2026-06-05T11:54:19+00:00

I have 2 session scoped beans 1)sessionholder1 2)sessionholder2 Both sessionholders have object UserVO in

  • 0

I have 2 session scoped beans

1)sessionholder1
2)sessionholder2

Both sessionholders have object UserVO in them

class SessionHolder1{
private UserVO user = new UserVO();
}

class SessionHolder2{
private UserVO user = new UserVO();
}

Now if i change some variable of the userVO in sesionholder1 it gets changed in sessionholder2 too.Is this behavior normal or is this due to bad design?

Is there any work around for this other than using clone() ?Kindly help.
Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T11:54:23+00:00Added an answer on June 5, 2026 at 11:54 am

    If you store the same UserVO object in both, then of course changing some field in one will change the field in the other. If you want two distinct objects, then create two distinct objects. If one is a copy of the other, the best way is to use a copy constructor:

    /**
     * Constructs a copy of the given userVO
     */
    public UserVO(UserVO userVO) {
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Session scoped bean @SessionScoped public class UserData implements Serializable { private
Assume I have a session scoped bean with object references in it, where the
I have a JSF application that makes much use of session-scoped variables. A new
I have already one session scoped CDI bean, which keeps currently logged in user
I have the following confguration in my JSF Spring application: <bean id=userSessionBean class=com.vanilla.beans.UserSessionBean scope=session>
I have a JSF session scope bean and I'm keeping current user(logged in) information
i have an managed bean(session scope) like this: class Home {// as homeBean public
I have a session-scoped bean in Spring that is set within the web context.
I have a session scoped managed bean, with a property current . If I
I have a session scoped bean in my @Controller: it is called SessionPreferences and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.