Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8364173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:22:06+00:00 2026-06-09T12:22:06+00:00

I wish to call a java class method from JSP whenever I submit my

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:22:08+00:00Added an answer on June 9, 2026 at 12:22 pm

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fragment where I wish to call a method from the FragmentActivity
Say I have a method that I wish to call which has an argument
I have an existing set of .net libraries that I wish to call from
I wish to execute a batch file and have it call itself 10 times.
I have some code where I wish to call a page method for each
I have a Java application in which I wish to call to another C++
Here's where I wish Java's String class had a replaceLast method, bu it doesn't
I have a web service that wish to call, and I want to pass
Hi there I am having an issue in JSP where I wish to call
I wish fetch data in a XML file, where Tag is a variable.. My

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.