Hi I have a servelt which is used to download txt/xml files from server to client PC... Once user clicks on the hyperlink in html file's..control moves to file download servlet which inturn will open an strean ,so user will be able to down load the file here is my html -------- <BODY BGCOLOR="#FFFFFF"> <a href='http://localhost:7001/FileDownloadServlet?fileSelected=one.txt' name="fileselected" value="one.txt"> one.txt </a> </body> --------- Here is my java servlet ------------------------------------------------------- public class FileDownloadServlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res)throws IOException,ServletException { System.out.println("line12"); doPost(req,res); } public void doPost(HttpServletRequest req, HttpServletResponse res)throws IOException,ServletException //public void service(HttpServletRequest req, HttpServletResponse res) throws IOException,ServletException { String fileSelected = req.getParameter("fileselected"); String fileWanted =""; System.out.println("file"+fileSelected); if(fileSelected.equalsIgnoreCase("one.txt")); else if(fileSelected.equalsIgnoreCase("two.txt")); String xxx = getServletContext().getRealPath("/"); System.out.println("line125"); String pathOfFile = "c:\trydownload"+ fileWanted; File F = new File(pathOfFile); res.setContentType("application/octet-stream"); res.setHeader("Content-Disposition","attachment;filename=\"" + fileWanted +"\""); ServletOutputStream out = res.getOutputStream(); InputStream in = null; try { in = new BufferedInputStream( new FileInputStream(F)); int ch; while((ch = in.read()) != -1) { out.print((char)ch); } } catch(Exception ex) { System.out.println(ex); } finally { if(in!=null) in.close(); out.close(); } } } ------------------------------------------------------- OS->win NT Appserver->Weblogic Kindly letme know where i am going wrong Any piece of code will help me thanks in adv __________________________________________________ Do You Yahoo!? Kick off your party with Yahoo! Invites. http://invites.yahoo.com/ ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
