Value of action attribute should be URL. The given URL specifies an address to which the data from the form should be sent when a form is submitted.
Use following html code in your jsp page:
<form action="uploadFile" method="post"
enctype="multipart/form-data">
<input type="file" name="file" />
<input type="submit" value="Upload file" />
Define mapping of servlet that responsible for loading a file in your web.xml
file:
<servlet>
<servlet-name>UploadServlet</servlet-name>
<servlet-class>package.UploadServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>UploadServlet</servlet-name>
<url-pattern>/uploadFile</url-pattern>
</servlet-mapping>
And implement the method doPost in given servlet in which call the method from your business logic:
protected void doPost(HttpServletRequest request, HttpServletResponse response) {
yourMethod();
}
You can specify any JSP page in attribute action
if you are using in your application only JSP:
<form action="upload_file.jsp" method="post" enctype="multipart/form-data">
This page will process a upload-file request in this case.