File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes forward problem after create excel file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "forward problem after create excel file" Watch "forward problem after create excel file" New topic

forward problem after create excel file

Eva Tang

Joined: Oct 06, 2003
Posts: 12
I have a servlet that create an excel file, I want it to forward to another url if the user chose to save the excel file. How now after saving the file it shouldn't foward. can anyone help?
public class DBHandler extends HttpServlet
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
FormBean f = (FormBean) request.getAttribute("formHandler");
try {
response.setHeader("Content-Disposition", "filename=" + f.getliner() + f.getmonth()
+ f.getyear() + ".xls");
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("sheet1");
sheet.setMargin(HSSFSheet.BottomMargin, 0.5);
sheet.setMargin(HSSFSheet.LeftMargin, 0.5);
sheet.setMargin(HSSFSheet.RightMargin, 0.5);
sheet.setMargin(HSSFSheet.TopMargin, 0.5);
HSSFDataFormat format = wb.createDataFormat();
HSSFPrintSetup ps = sheet.getPrintSetup();
ps.setScale((short) 80);
// Write the output
OutputStream out = response.getOutputStream();
getServletConfig().getServletContext().getRequestDispatcher("/jsp/dem/dem_display.jsp").forward(request, response);
catch (Exception e)
subject: forward problem after create excel file
It's not a secret anymore!