| Author |
where do we use response object?
|
Swetha Bhagavathula
Ranch Hand
Joined: Jan 04, 2011
Posts: 112
|
|
hi can anyone please tell me where can we use the response object parameter of
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest req,HttpServletResponse res)throws Exception....method .Ofcourse few usages are to refresh the page automatically to set header valus ,MIME types.etc..But as the use of response object is to send the response directly to browser window which is not possible,because Action class is not responsible to send the response (directly) to browser window.Moreover the result page of struts "Action' class like JSP program is responsible to send response to browser window..then where do we use this response object..?
|
SCJP5
|
 |
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8259
|
|
The fact is that Struts 1.x does a poor job of abstracting what is going on with responding to a request. That said, having access to the response object comes in handy sometimes, for example, for directly writing a response to the browser.
Struts 2 does a much better job of hiding the details.
|
"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
|
 |
Swetha Bhagavathula
Ranch Hand
Joined: Jan 04, 2011
Posts: 112
|
|
Joe Ess wrote:The fact is that Struts 1.x does a poor job of abstracting what is going on with responding to a request. That said, having access to the response object comes in handy sometimes, for example, for directly writing a response to the browser.
Struts 2 does a much better job of hiding the details.
thank you for your reply but can you please tell me what is the need of abstracting the response of a request?
|
 |
Joe Ess
Bartender
Joined: Oct 29, 2001
Posts: 8259
|
|
|
A good framework should shield the developer-user from the details of the implementation. By exposing the Servlets under Struts, we have a needlessly complex method signature as well as giving a developer-user opportunity to make some horrible mistakes. The design of Struts 2 is much more in keeping with the spirit of Object Oriented design because it hides the details of the implementation (and it is much easier to use compared to Struts 1).
|
 |
 |
|
|
subject: where do we use response object?
|
|
|