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 7543257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:22:43+00:00 2026-05-30T08:22:43+00:00

The below is my requirement. There is a screen in which an user enters

  • 0

The below is my requirement.

  1. There is a screen in which an user enters a file name and clicks on submit.

  2. On click of submit , a spring batch job must be triggered. The batch job reads the file and populates a database.

How do we call a spring batch job from a java code(specifically from a struts action class code ) ?

Also,I need to pass the file name(that the user entered on the screen) to the batch program. How do we achieve this ?

  • 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-05-30T08:22:44+00:00Added an answer on May 30, 2026 at 8:22 am

    JobLauncher

    Spring Batch jobs are launched (e.g. run) via a JobLauncher. One of the implementations of the launcher is provided by the framework that you can use outside of the box: SimpleJobLauncher. Take a look at the Configuring a JobLauncher section of the docs


    Running Jobs from within a Web Container

    While most of the time batch jobs are launched from a command line ( scheduled or not ), there are several ways to do it from the web. Take a look at Running Jobs from within a Web Container section of Spring Batch docs.

    The idea is simple. You just call jobLauncher.run from within a controller:

    @Controller
    public class JobLauncherController {
    
        @Autowired
        JobLauncher jobLauncher;
    
        @Autowired
        Job job;
    
        @RequestMapping("/jobLauncher.html")
        public void handle() throws Exception{
            jobLauncher.run(job, new JobParameters());
        }
    }
    

    This is Spring MVC (not Struts), but you can see it is very simple, and would work for any controller / action class:

    • jobLauncher and job are injected => setJobLauncher(…) / setJob(…)
    • jobLauncher runs the job from a jobLauncher.html page (note: the call to run does not block)

    Spring Batch Admin

    Another way to launch Spring Batch jobs without worrying about Spring MVC and Struts at all is to use a Spring Batch Admin which is there to solve this exact problem and more (monitoring / stopping / etc..)

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

Sidebar

Related Questions

I am developing a project in which there is one requirement that in a
I am trying to implement below flow in Spring Integration. Below is my requirement.
Could someone please help me with the code for below requirement or scenarios...I achieved
Below is my requirement. @echo off cls Set Sleep=0 :start echo This is a
I have a simple requirement as mentioned below: A ListView or any control displays
Please see the sample xml given below. As per a requirement, I need to
below is the code to download a txt file from internet approx 9000 lines
Below is my main activity file. I am stuck with the bottom area (commented
Below is how my screen look like ********************************************************* * Welcome to Mysite * *
Can you please suggest the best approach for my requirement(below) in Java. I have

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.