I wrote a HTML code to upload a file in jsp.now i have to take this data and work with it using a java program in jsp.can you please provide me a sample code of how to achieve this.
Thank you
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’m note sure about your code. Please follows these steps
Download the binary distribution of apache commons-fileupload and apache commons-io (FileUpload depends on Commons IO, so make sure you have the version mentioned on the dependencies page in your classpath before continuing.)
Extract both these distributions and copy
commons-fileupload-1.2.2.jarandcommons-io-2.0.1.jarunder WEB-INF/lib folder.In the Servlet, you need to import
javax.servlet,javax.servlet.http,import java.io,java.util,org.apache.commons.fileupload,org.apache.commons.fileupload.servletandorg.apache.commons.fileupload.disk packages.Demo:
Create a servlet file under WEB-INF/classes folder
Configure/register the servlet in WEB-INF/web.xml
Content of the view (upload.jsp).
NOTE: Set enctype attribute of with “multipart/form-data”
Content of success.jsp and fail.jsp
Create a folder named
uploadat root ofcontext.JSP version (This is not a recommended way)
upload1.jsp
showfile.jsp