I wish to call a java class method from JSP whenever I submit my form.
My JSP file will have a file tag.
User will browse a file from his local machine. And click on Submit.
This file object should be available in a Java class where I will have my business logic.
Is this possible without using struts?
<s:form action="**direct call to Action method here**" method="post" enctype="multipart/form-data" >
<s:file name="userImage" label="User Image" /><s:submit />
Please help me with the ways of doing this.
thanks.
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:
Define mapping of servlet that responsible for loading a file in your
web.xmlfile:And implement the method doPost in given servlet in which call the method from your business logic:
You can specify any JSP page in attribute
actionif you are using in your application only JSP:This page will process a upload-file request in this case.