It's not a secret anymore!
The moose likes Struts and the fly likes How to handle global parameters in Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to handle global parameters in Struts " Watch "How to handle global parameters in Struts " New topic

How to handle global parameters in Struts

Rishi Singh
Ranch Hand

Joined: Dec 09, 2000
Posts: 321
Hi All,
I have not fully explored Struts , though we have modified the required components as per our requirements and using it, I would like to know how to handle global parameters in Struts which are used for almost every other request/response .
As per Struts,Request handlers are cached by Request processors when first created and subsequently made available to other incoming request.So is there a global configuration object which is polled and made available to the request handler when required.Would like inputs from people using it and Ted...
Rishi Singh
Ted Husted
Ranch Hand

Joined: Dec 02, 2002
Posts: 37
Generally, you would just tuck that away in the application (or servlet) context under a predetermined name. The Struts tags (and Velocity View tools) will check all the scopes for any object referenced in a presentation page.
Within in an Action, you can access the object directly. The Controller servlet is provided as a member variable, so you have access to all the servlet methods.
In Struts 1.0, a helper servlet was often used to load such parameters (though you could also subclass the ActionServlet if you wanted). In Struts 1.1, there is a PlugIn interface for Actions, which you can use to load global resources like this.
HTH, Ted.

<a href="" target="_blank" rel="nofollow">Struts in Action</a>
wood burning stoves
subject: How to handle global parameters in Struts
jQuery in Action, 3rd edition