| Author |
error locating file in servlet
|
Adewale Adebusoye
Ranch Hand
Joined: Sep 28, 2005
Posts: 118
|
|
I am trying to download a file from a servlet. Ive put in all my codes but i keep getting a "error locating requested file" error in DAP, with the URL of the file. Is there anything that can be done? thanks
|
"Human beings can alter their lives by altering their state of mind" William James
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56554
|
|
|
Please read this.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Adewale Adebusoye
Ranch Hand
Joined: Sep 28, 2005
Posts: 118
|
|
Well i'm sorry for not beein explanatory enough. this is my get method for downloading my attachments public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String filename=request.getParameter("filename"); File f=new File("C:/TEMP"+"/"+filename); FileInputStream input=new FileInputStream(f); BufferedInputStream in = null; try{ in = new BufferedInputStream(input); response.setContentType(CONTENT_TYPE); response.setHeader("Content-Disposition"," inline; filename=" + filename); ServletOutputStream out = response.getOutputStream(); byte[] buffer = new byte[4 * 1024]; int data; while((data = in.read(buffer)) != -1){ out.write(buffer, 0, data); } out.flush();} catch(Exception e){ return; } } filename is a parameter sent from my jsp page to the servlet via url rewriting. When i click on the link representing the file to be downloaded, DAP tells me "proxy cannot find requested file" Also C:\TEMP is the folder that i upload my files to.
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
DAP tells me "proxy cannot find requested file" What is DAP? Is that a 404 error coming from the server? Are you sure you're even hitting that servlet? What are you seeing in the server's logs?
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Adewale Adebusoye
Ranch Hand
Joined: Sep 28, 2005
Posts: 118
|
|
DAP is download accelerator Plus, it helps me manage my downloads. And im not so sure if im hitting the servlet cus i once out a println statement to print the parameter, and it didnt show. but the servlet name is called showattachments and the url from the preceeding jsp is like this <a href="showattachments?filename=<%=f.getName()%>"><%=f.getName()%></a> so it should hit the servlet but maybe it isnt. im using JBuilder IDE so i dont know where to find my server logs though ive looked.
|
 |
 |
|
|
subject: error locating file in servlet
|
|
|