Hi, I have an application, where i need to export a particular report to Ms Word Format. When i click on Export Link, a pop-up window opens up with options to export in Ms Word/Excel etc. After i click on Ms Word, the pop-up window closes and the form is then submitted the servlet which exports the data to MS Word. However, if the user doesn't closes the exported word document browser and again decides to export another report, the first exported doc within the browser bocomes blank. I dont want this to happen... Also i have tried the timeout() method.. but i dont want to use it.. Code:- "Export Link.jsp" <%@ page contentType="text/html;charset=windows-1252"%> <% String strTemp = new java.util.Date().toString(); %> untitled <script type="text/javascript"> var i = 0; var winPopup; if (winPopup != undefined) { winPopup.close(); } function showRTF() { var tempName = "newWin" + i; winPopup = window.open("", tempName, "width=300,height=400,scrollbars=yes,menubar=yes,resizable=yes,toolbar=yes,location=no, target=_self"); setTimeout('winPopup.close()',3000); i++; window.document.formShowRTF.target = tempName; window.document.formShowRTF.submit(); setTimeout('self.close()',4000); } </script>

The following EXPORT OPTIONS:

MS Word ------------------------------------------------------------ "ExportServlet.java" package mypackage; import java.io.IOException; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class ExportServlet extends HttpServlet { private static final String CONTENT_TYPE = "text/html; charset=windows-1252"; private int i = 0; private String newName = "newStr"; public void init(ServletConfig config) throws ServletException { super.init(config); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("application/msword"); //this opens diff word docs //response.setHeader("Content-Disposition", "attachment; filename="+ newName+".doc"); //response.setHeader("pragma","no-cache"); ServletOutputStream os = response.getOutputStream(); response.setHeader("Content-disposition", "attachment; filename" + "Example.doc" ); String strTemp = request.getParameter("RTFData"); //os.print(strTemp); os.write(strTemp.getBytes()); os.flush(); //os.close(); //response.flushBuffer(); } public void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("application/msword"); //response.setHeader("Content-Disposition", "attachment; filename=abc.doc"); //response.setHeader("Content-Disposition", "inline; filename=abc.doc"); //response.setHeader("pragma","no-cache"); ServletOutputStream os = response.getOutputStream(); String strTemp = request.getParameter("RTFData"); System.out.println("data: " + strTemp); os.write(strTemp.getBytes()); os.flush(); os.close(); //response.sendRedirect("http://192.168.1.77:8988/SampleApplication/servlet/mypackage.FinalServlet"); } }