0

Hi I wrote the below code in a jsp file to upload a file. But before I upload I want to display the entire path of the file in the current jsp itself

 <form method="post" action="SendTheFileName">
            <div id="Files_to_be_shared"> 
                  <input type="file" id="File" name="FileTag" />
                  <input type="submit" value="Share" /> 
           </div>
 Complete path of the file is <%=request.getParameter("File");%>//Is this correct?

I am not getting the complete path value. I get null instead. Can you please let me know how to get the complete path in the current jsp itself

1 Answers1

0

Jsp's are made on the server and file is uploaded by user, in browser, by the time it will be uploaded - there will be no scriplets on your html page at all, meaning those parameter value will be tried to obtain during jsp creating, where it is obviously null(unless request really contains such value). To run code on the client use javascript, for example here is how to do what you want using javascript.

P.S. consider using EL, scriplets are considered harmful, there are plenty of info about this on the net

Community
  • 1
  • 1
Dmytro Grynets
  • 923
  • 11
  • 29
  • @ Dmytro Grynets I am not getting the full path when I tried your example. I only get the file name –  Feb 15 '17 at 15:00
  • You don't get the full path, well, because you generally [can't do so](http://stackoverflow.com/questions/15201071/how-to-get-full-path-of-selected-file-on-change-of-input-type-file-using-jav) – Dmytro Grynets Feb 15 '17 at 15:03