You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Daniel Jaffa <ja...@courtinnovation.org> on 2002/11/18 22:42:53 UTC
Problem with forward
Ok, i have an action that creates a pdf. The action then forwards it self
to a Servlet that should display the just generatered PDF.
When i call the servlet directly it works fine
http://10.132.240.33:82/domesticviolence/GenPDF/
but when my Action forwards to the servlet nothing happens
<forward name="dataLoaded" path="/GenPDF/" redirect="true"/>
I get no error messages, or any HTML error page.
I know that ie has a problem with the length of the response object but i am
handling that correctly.
Any idea on how to fix the problem.
Daniel Jaffa
public class Transform
{
public void Transform() {}
private static Logger logger = Logger.getLogger(Transform.class);
public static void action (HttpServletRequest request, HttpServletResponse
response)
{
javax.servlet.ServletOutputStream ostream;
FileInputStream fis;
byte[] theByte;
try {
String orderNumber = (String) request.getAttribute("orderNumber");
String formApprovedID = (String) request.getAttribute("formApprovedID");
RegistryBean myForm = (RegistryBean) request.getAttribute("myForm");
theByte = FileByte.convertFileToByte("/pdf/myfile.pdf");
ostream = response.getOutputStream();
response.setContentType("application/pdf");
ostream = response.getOutputStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
FileInputStream from = new FileInputStream("/pdf/myfile.pdf");
byte[] buffer = new byte[4096];
int bytes_read;
while((bytes_read = from.read(buffer)) != -1)
{
baos.write(buffer, 0, bytes_read);
}
response.setContentLength( baos.size());
baos.writeTo(ostream);
ostream.flush();
ostream.close();
response.flushBuffer();
logger.debug("Buffer Size" + response.getBufferSize());
logger.debug("isCommitted()" + response.isCommitted());
} catch( Exception e) {System.err.println(e);}
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>