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]