wood burning stoves 2.0
The moose likes Servlets and the fly likes error locating file in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "error locating file in servlet" Watch "error locating file in servlet" New topic

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?

"Human beings can alter their lives by altering their state of mind" William James
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63838

Please read this.

[Asking smart questions] [About Bear] [Books by 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;
in = new BufferedInputStream(input);
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); }
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

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.
I agree. Here's the link: http://aspose.com/file-tools
subject: error locating file in servlet
It's not a secret anymore!