This is basically a ‘best practices’ question. Struts 1 forms have getters and setters for retrieving/setting form properties. Should they be used for just that, or a getter (let’s say) can have logic (or some form of pre-processing) that potentially modifies the property before giving it to the jsp/action? Another alternative is to use the logic (or the same pre-processing) in the action class before setting it into the form attribute (and hence, the getter will be free of this processing).
Which one is the recommended way ?
It depends entirely on your needs and the context of what you’re actually doing.
Actions, however, should be as lean as possible–they exist as the layer between the web page and the business logic. If they’re doing much beyond marshalling data between the layers, something’s wrong.
There’s no way to answer this question in a general way. IMO getters and setters should be as logic-free as possible, no more, no less.