How to Call a JSP in between from Struts Action Class while processing a text file?

Posted on 2006-05-24
Last Modified: 2010-04-01
Hi All,

I'm processing a text file i.e in the struts action class.. reading each line of text file and tokenizing it and consturcting an value object
and passing it to an EJB. If the text file contains 1500 records(lines) and if it is takinig more
than 5000 milli seconds to process the 1500 lines, then instead of making wait the user, i
would like to send a confirmation number, by which he can check the status afterwards.

My concern is if the processing time is more than 5000 ms , then i need to call a JSP from my
struts action class and will display the confirmation number to the user, but in the background
the processing should be going on till all the lines in the file gets completed.

How can i call a JSP from Action class in between while the text file is  processing .

Question by:ramsin112400
    1 Comment
    LVL 4

    Accepted Solution

    How about starting up a new thread
    Make this processing of records a seperate class
    Have it implement "runnable"

    public class FileProcessor implements Runnable{
      public void run(){
        // code to process one file

    then in your Action you do something like this:

    Thread processThread = new Thread(new FileProcessor(fileToProcess));
    return mapping.findForward("started");

    Starting a different thread lets you pass off the work somewhere else, and return control to struts, where it can send the confirmation page.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Stuck in Bootstrap WysiHtml Editor 3 33
    issue with pdf generation 2 74
    mask rule in struts validation.xml 5 54
    java operators 3 71
    David Varnum recently wrote up his impressions of PRTG, based on a presentation by my colleague Christian at Tech Field Day at VMworld in Barcelona. Thanks David, for your detailed and honest evaluation!
    Local Continuous Replication is a cost effective and quick way of backing up Exchange server data. The following article describes the steps required to configure Local Continuous Replication. Also, the article tells you how to restore from a backup…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now