This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "error locating file in servlet" Watch "error locating file in servlet" New topic
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: 60785
    
  65

Please read this.


[Asking smart questions] [Bear's FrontMan] [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;
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
 
Similar Threads
Problem reading file: Bad file descriptor
error locating file
Problem with JavaBeans.HELP.URGENT
GUI Design
Javac:File Not Found