Home arrow static arrow Java Programming [Archive] - Writing to the Response object in Struts
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Writing to the Response object in Struts
This topic has 1 reply on 1 page.

Posts:346
Registered: 1/15/04
Writing to the Response object in Struts  
Aug 3, 2004 2:00 AM



 
Hi,
In a servlet's doGet method to write to the response object is simply a matter of
Response.getWriter().println("my data");

The struts docs says that for extensibility the Response and Request objects are passed into the Action Objects perform method.
So in the Action's perform method why does
Response.getWriter().println("my data");
not send any data back to the client?
 

Posts:14,142
Registered: 99-04-02
Re: Writing to the Response object in Struts  
Aug 3, 2004 7:09 AM (reply 1 of 1)



 
because the Action expects to foward to a JSP page for the output, and when forwarding, anything written to out (response.getWriter()) will be cleared before the forward happens, thus dropping whatever you wrote out. If you want to write something out, you'd have to store the object as a request attribute and pull it out in the JSP that you forward to.
 
This topic has 1 reply on 1 page.