aspose file tools*
The moose likes Spring and the fly likes how to set the scope of an object in controller Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "how to set the scope of an object in controller" Watch "how to set the scope of an object in controller" New topic
Author

how to set the scope of an object in controller

saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
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

Joined: Feb 05, 2001
Posts: 17249
    
    6

Please add more detail. Not sure what you mean by scope here, or created in Controller means.

Thanks

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Suhas Bilaye
Ranch Hand

Joined: Sep 10, 2009
Posts: 80
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


Thanks and Regards,
Suhas
http://www.xplore-java.blogspot.com/
saipraneeth nallapareddy
Ranch Hand

Joined: Dec 02, 2009
Posts: 159
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

Joined: Dec 02, 2009
Posts: 159
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

Joined: Dec 02, 2009
Posts: 159
i am once again stuck i am able to get the object but not its content.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to set the scope of an object in controller
 
Similar Threads
ActionForm
How to store an object in 'application' scope in Spring when the server is started?
how to print values on jsp page fetched from servlet
Memory Leak
How to display records in Grid view format in Jsp