Results 1 to 2 of 2

Thread: In Spring MVC, how to pass an HttpSession to a bean?

  1. #1
    Join Date
    Apr 2005
    Posts
    5

    Default In Spring MVC, how to pass an HttpSession to a bean?

    Hi all,

    In Spring MVC, how could I pass an HttpSession object to a bean other than a controller such that I could create an instance of that bean based on an attribute stored in the HttpSession. Then, the new instance will be injected to a controller via setter injection.

    Thanks in advance!

    Nathan

  2. #2
    Join Date
    Apr 2005
    Location
    Wilhelmshaven, Germany
    Posts
    15

    Default

    The instances of your bean are different and are depending on an attribute in the session. Right?

    What i would do:

    Create a custom factory for your bean and inject this factory (not the bean) into your controller. Then, in your controller, ask the factory for a new object and pass the session as an parameter to your factory. Now do the init work in your factory and the bean will not depend on the session api.

    But why do you need this? Maybe there is a better way.

    Best regards,

    Roman

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  5. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •