Thanks Ben,
I am using JRun4. Today I have changed the code and I am able to get the file download box.
But then I get an error in JRun console.
Details of the problem I am facing:
----------------------------------
My JSP page 'LoadExclusionCharges.jsp' has an 'Export' button.
Onclick of this button, a javascript function UploadAction() is invoked.
This JS fn. is expected to provide the file download dialog box.
Part of the code is given below:
// JS fn.
function UploadAction()
{
frmObj = ev al(document.forms[1]);
//
java code
String uploadFlag = request.getParameter("upload");
if("true".equals(uploadFlag)){
File f = new File ("C:/Projects/ChargeMaster/cmdev/web/tempuploaddir/exportResult.csv");
response.setContentType ("application/text");
String name = f.getName().substring(f.getName().lastIndexOf("/") + 1,f.getName().length());
response.setHeader ("Content-Disposition", "attachment;filename=\""+name+"\"");
InputStream in = new FileInputStream(f);
ServletOutputStream outs = response.getOutputStream();
int bit = 256;
try {
while ((bit) >= 0) {
bit = in.read();
outs.write(bit);
}
} catch (IOException ioe) {
ioe.printStackTrace(System.out);
}
outs.flush();
outs.close();
in.close();
}
//end of java code
frmObj.action="cm_default_action.do?destination=cm_load_exclusioncharges&upload=true";
frmObj.submit();
}
.
.
.
.
// html code calling the JS fn.
input type="button" name="Export" value="Export" class="graybutton" on click="UploadAction()"
.
.
.
With this code, when I click on the 'Export' button, the file gets opened.
But then I get an error in the console as : ANY IDEA WHY THIS ERROR IS THROWN
java.lang.IllegalStateException
at jrun.servlet.JRunResponse.getWriter(JRunResponse.java:195)
at jrun.jsp.runtime.JRunJspWriter.initPrintWriter(JRunJspWriter.java:76)
at jrun.jsp.runtime.JRunJspWriter.flush(JRunJspWriter.java:122)
at jrun.jsp.runtime.JRunJspWriter.flush(JRunJspWriter.java:111)
at java.io.PrintWriter.flush(PrintWriter.java:120)
at jrun.jsp.runtime.JRunJspWriter.flush(JRunJspWriter.java:131)
at jrun.jsp.runtime.JRunJspWriter.flush(JRunJspWriter.java:111)
at jrun.jsp.runtime.JRunJspWriter.check(JRunJspWriter.java:356)
at jrun.jsp.runtime.JRunJspWriter.write(JRunJspWriter.java:312)
at java.io.Writer.write(Writer.java:126)
at jrun.jsp.runtime.JRunJspWriter.print(JRunJspWriter.java:147)
at jrun.jsp.runtime.JspWriterWrapper.print(JspWriterWrapper.java:148)
at jrun__chargemaster__common__Header2ejsp1f._jspService(jrun__chargemaster__common__Header2ejsp1f.java:72)
at jrun.jsp.runtime.HttpJSPServlet.service(HttpJSPServlet.java:43)
at jrun.jsp.JSPServlet.service(JSPServlet.java:119)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at jrun.servlet.JRunRequestDispatcher.invokeNext(JRunRequestDispatcher.java:439)
at jrun.servlet.JRunRequestDispatcher.include(JRunRequestDispatcher.java:371)
at jrun.jsp.runtime.JRunPageContext.include(JRunPageContext.java:355)
at jrun.jsp.tags.Include.doit(Include.java:35)
at jrun.jsp.tags.RequestDispatchTag.doEndTag(RequestDispatchTag.java:47)
at jrun__chargemaster__admin__LoadExclusionCharges2ejsp2c._jspService(jrun__chargemaster__admin__LoadExclusionCh
arges2ejsp2c.java:180)
at jrun.jsp.runtime.HttpJSPServlet.service(HttpJSPServlet.java:43)
at jrun.jsp.JSPServlet.service(JSPServlet.java:119)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at jrun.servlet.JRunRequestDispatcher.invokeNext(JRunRequestDispatcher.java:439)
at jrun.servlet.JRunRequestDispatcher.forwardInvoke(JRunRequestDispatcher.java:409)
at jrun.servlet.JRunRequestDispatcher.forward(JRunRequestDispatcher.java:178)
[ March 08, 2005: Message edited by: Gayathri RS ]