This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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)
I agree. Here's the link:
subject: forward problem after create excel file
It's not a secret anymore!