简体   繁体   中英

Read a file from remote system using jsp

We can read a text file using JAVA program on a localhost.

My problem is , I want to read a file using JSP which is on a client's system . When he runs a JSP using his browser.This JSP should read the file.

Is this possible or not?

And if yes , how this can be achieved?

No, it's not possible.

First of all, because the JSP is excuted on the server, and not on the client machine.

Second, because if a random web page could read files on your computer, it would be a major security risk. You can let the user choose a file and upload it to your web server, though.

Also, JSPs are view components. Their goal is to generate markup, and they shouldn't contain any line of Java code: only the JSP EL, and JSP tags. For anything else, use Java files.

Sorry I cant just comment. But, wouldn't there be a restriction on the browser not being able to access files on the client?

Perhaps the way to do this is to prompt for the file to be uploaded to be processed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM