Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to set the scope of an object in controller

 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello everyone

i am working with spring&hibernate, i want to set scope to an object that is created in the controller.

can anyone help me in this regard.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please add more detail. Not sure what you mean by scope here, or created in Controller means.

Thanks

Mark
 
Suhas Bilaye
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If you mean to say that you are using a dependency injection for an object in the controller then in that case you can use the scope attribute for the bean tag.
It will be more clear if you elaborate on the type of problem that you are facing... and need for setting the scope of the object.

Regards,
Suhas
 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for your replies, sorry for not making the point so clear.

let me make it more clear, i want to access an object in all my jsp's(at-least in more than one), the object which i am talking about will be returned from my controller as a model object(ModelAndView), the object gets its content by making a dao call in my controller, now i want to set the scope for this object (preferably session scope) so that i can access my object in more than one jsp.

i also used ServletContextAware interface, whose implementation class has been injected into spring configuration xml file as a bean, i cannot use this way because my dao call depends on some parameters. now let me know which way i have to use to set the scope of the object so that i can access in any of my jsp.
 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have finally rectified that
thank you for those who have come across this post and posted their replies.
come up even with your solution as your approach may be different with mine.

i hve set in my controller class using
 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am once again stuck i am able to get the object but not its content.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic