Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to read a text file in a JSP?

Status
Not open for further replies.

xumingxian

Programmer
Oct 31, 2003
5
0
0
US
I try to read a list of parameters from a user specified text file (a tab delimited *.txt in Excel), which stored in user's local driver. These parameters will be insert into a database table as one of criteria for a user's query. I can not use a JavaBean to do this due to the server-side JavaBean does not recognize any user's local driver. If a javascript in client-side could copy this *.txt to a designated network mapped driver, then a JavaBean can process this file to act on database.

I don't know how to implement this via javascripts. Please help! Thanks in advance
 
If Javascript could read files on the local drive, then it could copy the data in the files to form fields and send them to the web server; you know things like my .pst files, where my address book is stored, and other good stuff. So that would be a big security problem. I don't think Javascript is allowed to do that.

Could you provide your users with a form field for uploading that text file; save it on your server and then read it?

Code:
<input type=&quot;file&quot; name=&quot;my_criteria&quot;>
 
Thanks for the help.
I do have the form for user to enter queryName and fileName. I used a javascript to check if both get entered. But I don't know how to &quot;upload&quot; the text file.
 
OK here is what I found in the Java forum by searching on jsp file upload.



You need something on the server-side to process the file which is sent in the request body. Superficial look at the above link appears to be what you are looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top