Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error locating file in servlet

 
Adewale Adebusoye
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64981
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this.
 
Adewale Adebusoye
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Adewale Adebusoye
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic