Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

How can I get a file from client,and read it?

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I make an applet,and use "FileDialog" class to choose a file and send its path to my servlet.When a client choose a file and sent its path to my servlet,why does my servlet search his file at my computer but not at his computer?
What shall I do? Should I get the URL of his file?
 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
When the file path reaches the servlet, for the servlet this path is relative to the servlet directory or the root directory in the same system.The servlet cannot access the client's system.So you cannot make the servlet read any client's file on its own. However you have two ways:
1. Make the applet trusted(by third party) so that it can read any client's file directly and send the contents to the servlet. For the servlet the file content will simply be a data stream sent by the applet.
2. Use the HTML file upload: <INPUT TYPE=FILE> to upload the file to the servlet.For this you might want to read a good book: Java Servlet Programming-OReilly.
hope this helps
Tanveer
 
chenw
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Thanks for your answer.Could you tell me how to make the applet trusted in details?
 
Make yourself as serene as a flower, as a tree. And on wednesdays, as serene as this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic