using JSP to read a file from the local file system
I need to read a file from the local file system using JSP, save it as a string , and send it to a 开发者_如何学编程webservice(deployed using glassfish) for processing. Can anyone suggest how to perform File IO using JSP?
Thanks, Deepak.
Doing File I/O from a JSP is the same as doing it normally: Just use the java.io
or java.nio
classes. If you need to map a virtual path to a real one, you can use ServletContext#getRealPath
.
Technically, I tend to agree with T.J. here. But actually its not the same, its a bad idea altogether.
If you want to upload a file to the server and process it, then use a html form with fileupload field and select the text file and submit the form . the file will be uploaded to the server where you can process it
http://www.java-tips.org/java-ee-tips/javaserver-pages/uploading-file-using-jsp.html
精彩评论