• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

error locating file in servlet

 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please read this.
 
Adewale Adebusoye
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
She said she got a brazillian. I think owning people is wrong. That is how I learned ... tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic