return null from the action instead of returnign a forward.

-----Original Message-----
From: Vasudevrao Gupta [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 03, 2004 3:58 PM
To: 'Struts Users Mailing List'; 'Satya Narayan Dash'
Subject: Viewing .pdf files usign struts frames work..



Hi All,

I am trying to view a pdf file using struts frame work..
I am able to view the file ,but it throws an illegalStateException as struts
forward the request after I send the output stream.

Below is the action mapping:
<action name="enquiryFormBean"
                                path="/viewScannedFile"
                                scope="request"

type="com.rwe.thameswater.els.enquiry.action.ViewScannedFileRefAction"input=
"/screens/enquiry/jsp/ADS_ELS_CreateEnquiry.jsp"
validate="true">
<forward name="SUCCESS" path="/screens/enquiry/jsp/ADS_ELS_ScannedFile.jsp">
                        </forward>
</action>

below is the action class execute() method:
try {

                        MessageResources resource = this.getResources(request);
                        String scannedFileFolder = (String)
resource.getMessage(ELSEnquiryConstantsIF.SCANNED_FILE_LOCATN);
                        System.out.println("scannedFileFolder>>"+scannedFileFolder);
                        String scannedFileExtn = (String)
resource.getMessage(ELSEnquiryConstantsIF.SCANNED_FILE_EXTN);
                        System.out.println("scannedFileExtn>>"+scannedFileExtn);
                        String scannedFileLocation = scannedFileFolder +
request.getParameter("scannedFileReference") + scannedFileExtn;
                        
System.out.println("scannedFileLocation>>"+scannedFileLocation);
                        String contentType = (String)
resource.getMessage(ELSEnquiryConstantsIF.SCANNED_FILE_CONTENT);
                        System.out.println("contentType>>"+contentType);
                        response.setContentType(contentType);
                        File pdfFile = new File(scannedFileLocation);
                        response.setContentLength((int) pdfFile.length());
                        FileInputStream in = new FileInputStream(pdfFile);
                        request.setAttribute("FILE",in);
                        OutputStream out = response.getOutputStream();

                        byte[] buf = new byte[4096];
                        int count = 0;
                        while ((count = in.read(buf)) >= 0) {
                                out.write(buf, 0, count);
                        }
                        out.flush();
                        in.close();
                        out.close();
                } catch (Exception e) {

                        // Report the error using the appropriate name and ID.
                        System.out.println("Exception found while viewing>>"+e);
                        errors.add("name", new ActionError("id"));

                }
                return (mapping.findForward("SUCCESS"));
}

Please suggest me anyother alternative using the struts framework



Confidentiality Notice 

The information contained in this electronic message and any attachments to this 
message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged 
information. If
you are not the intended recipient, please notify the sender at Wipro or [EMAIL 
PROTECTED] immediately
and destroy all copies of this message and any attachments.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to