P
PythonAnimal
I keep getting this error using Eclipse and Tomcat. I went over my
code a 100 times and I do not close the output stream or do I make more
than one call here is my code.
I call the method( HttpServletRequest req, HttpServletResponse resp)
then I do a
RequestDispatcher _view = req.getRequestDispatcher("/errorPage.jsp") ;
// return to error
_view.forward(req,resp);
and I get the illegalstateExceptionerror
method( HttpServletRequest req, HttpServletResponse resp)
{
try{
// set approriuate data for returning a file ot type .csv
resp.setContentType("application/vnd.ms-excel");
resp.setContentLength((int) _outputFile.length());
resp.setHeader("Content-Disposition","attachment; filename=\"" +
_outputFile.getName() + "\"");
outStream = resp.getOutputStream();
byte[] buf = new byte[8192];
FileInputStream inStream = new FileInputStream(_outputFile);
int sizeRead = 0;
// write to resp stream
while((sizeRead = inStream.read(buf, 0 , buf.length)) > 0) {
outStream.write(buf, 0 , buf.length);
}
}catch(Exception e) {System.out.println("ERROR");
e.printStackTrace();
return false;
}
return true;
}
// Here is my forward
RequestDispatcher _view = req.getRequestDispatcher("/errorPage.jsp") ;
// return to error
_view.forward(req,resp);
I just can not forward to another page after writing, I did this same
code on a different m achine.
Thanks so much!! I am dieing over here trying to figure thius forward
out!!!! using newest SDK.
code a 100 times and I do not close the output stream or do I make more
than one call here is my code.
I call the method( HttpServletRequest req, HttpServletResponse resp)
then I do a
RequestDispatcher _view = req.getRequestDispatcher("/errorPage.jsp") ;
// return to error
_view.forward(req,resp);
and I get the illegalstateExceptionerror
method( HttpServletRequest req, HttpServletResponse resp)
{
try{
// set approriuate data for returning a file ot type .csv
resp.setContentType("application/vnd.ms-excel");
resp.setContentLength((int) _outputFile.length());
resp.setHeader("Content-Disposition","attachment; filename=\"" +
_outputFile.getName() + "\"");
outStream = resp.getOutputStream();
byte[] buf = new byte[8192];
FileInputStream inStream = new FileInputStream(_outputFile);
int sizeRead = 0;
// write to resp stream
while((sizeRead = inStream.read(buf, 0 , buf.length)) > 0) {
outStream.write(buf, 0 , buf.length);
}
}catch(Exception e) {System.out.println("ERROR");
e.printStackTrace();
return false;
}
return true;
}
// Here is my forward
RequestDispatcher _view = req.getRequestDispatcher("/errorPage.jsp") ;
// return to error
_view.forward(req,resp);
I just can not forward to another page after writing, I did this same
code on a different m achine.
Thanks so much!! I am dieing over here trying to figure thius forward
out!!!! using newest SDK.