how to get full path for upload a file in jsp?

34,212

Solution 1

JSP is indeed a Server side technology. Here are few of the links to do a file upload using JSP.

http://www.tutorialspoint.com/jsp/jsp_file_uploading.htm

http://corejavaexample.blogspot.in/2013/04/how-to-upload-file-in-jsp.html

http://javarevisited.blogspot.in/2013/07/ile-upload-example-in-servlet-and-jsp-java-web-tutorial-example.html

Hope this may help solve your issue.

Solution 2

JSP is code that produces the client facing HTML code (commonly called the View) and the Servlet is server code. In reality they will be on different machines, so what is the use of the full path. The file contents should be POSTED to the servlet when submitting your form.

your jsp should something like:

<form action="UploadServlet" method="post"
                        enctype="multipart/form-data">
<input type="file" name="file" size="50" />
<br />
<input type="submit" value="Upload File" />
</form>

Of course you have other input fields as well.

See this link

How to upload files to server using JSP/Servlet?

Share:
34,212
sathya
Author by

sathya

Working as a Android developer

Updated on July 09, 2022

Comments

  • sathya
    sathya almost 2 years

    In my jsp page, use file uploading and pass file for string to java page for copy to particular folder. I want whole path for copying my file. but i get only a file name with extension.

    scan file : ABC.pdf

    it show only : ABC.pdf

    i want to show: c:/abc.pdf

  • Scary Wombat
    Scary Wombat about 10 years
    Maybe show some code and I can be more specific. JSP should be used to show the View to your user on the browser. When data is POSTED (submitted / file uploaded) it should be sent to a servlet running in a Java Application Server like Tomcat. The users browser (maybe 100's of users) will be running on a different machine to the servlet.
  • Alexandre Lavoie
    Alexandre Lavoie about 10 years
    JSP is not client side code, JavaScript, HTML, CSS are.
  • Scary Wombat
    Scary Wombat about 10 years
    I have edited my answer to (whilst trying to keep it easy) explain the differentiation of the use of JSP vs Servlet code
  • sathya
    sathya about 10 years
    @Java1 I want to upload it. if i have path.. i pass it as a String to servlet and easily i upload it.. If you know how to pass file to servlet from jsp?
  • Scary Wombat
    Scary Wombat almost 10 years
    @AlexandreLavoie I do not think I ever said that JSP was client code. I said that it produces HTML code.
  • Sitansu
    Sitansu over 7 years