• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Abhishek Tanwar

I build web & mobile experiences

  • HOME
  • BLOG
  • CONTACT ME
  • DISCLAIMER & COPYRIGHTS
You are here: Home / Tips & Tricks / How to implement offline struts actions?

How to implement offline struts actions?

July 16, 2018 by Abhishek Tanwar

This is part 2 of my first post. This is my way to efficiently handle offline struts actions and notify the status as GET API requests. Entire code is available on my Gitlab (@tony2k84). I have included the link at the bottom of the post.

Let’s begin.

Folder Structure

First, my folder structure. I have divided into JSPs, listeners, API, pojo, struts classes and core framework. I will describe each one in summary below.

folder-structure
folder-structure

 

Request and Response JSP

To get the concept going, I have basic action input (form) and output redirection JSPs.

Request and Response JSPs
Request and Response JSPs

Nothing fancy here. Just a simple JSP submitting the form to a struts action and struts action REDIRECTING (not just forwarding) the result to a JSP.

Web.xml and Struts Config

Web.xml
Web.xml
Struts Config
Struts Config

 

Rest APIs

This just gives the access to the status via APIs

The Framework

This is the main part. It has 2 components.

TaskManager

This is responsible for handing all tasks. The main responsibilities includes:

  1. Singleton access to the same
  2. Managing pending tasks
  3. Managing task updates
  4. Managing thread pool
  5. Synchronizing secured access to the task processing.

Task Processor

This is responsible for handling one task. This could be your business logic class to handle one task. For sake of simplicity I have considered some fake processing and some updates to the task manager.

Context Listener

This calls to handle the memory leak while starting the threads and stopping them post application load and unload.

Context Listener
Context Listener

 

Thats it. Above gets the things going. If we talk about the use cases for this, from the top of my head I can think of:

  1. Handling long running order submission for B2B orders where you cant allow the order to enter database without validation and cant let users stuck on one screen to complete.
  2. Handling bulk actions for a simple operation.

Part 3 will be coming soon with a React GET APIs to get the order updates. Subscribe for more.

Future extensions can include handling resubmit of tasks in case it fails. I will happy to do a POC in future if someone is interested. What are your thoughts on this concept? Feel free to comment how you will implement the same.

The entire code is hosted in Gitlab to try out @ struts-offline-actions!

Share this:

  • Facebook
  • X

Like this:

Like Loading...

Filed Under: Tips & Tricks Tagged With: offline action processing, offline actions in struts, PRG in struts, struts, threads in struts

Primary Sidebar

  • Behance
  • Email
  • Facebook
  • GitHub
  • LinkedIn

Popular Posts

How To Integrate React in JSP Application
SaaS, PaaS, IaaS
XQuery highlighting in Notepad++
Standard Design Patterns – Applied to JAVA
XQDT Installation on Eclipse JUNO

Categories

  • Building APIs
  • Building Mobile Apps
  • Building Web Apps
  • Coding Challenges
  • Extensions
  • Fullstack
  • Patterns
  • Tips & Tricks
  • Uncategorized
  • VSCode

Tags

2022 vscode extensions Abstract Factory alienware amazing vscode extensions apple challenges coding coding-challenges Design Patterns dota2 dota2 items dynamic web service call dynamic webservice invocation enterprise integration express flex helpful vscode extensions how to implement mfa in nodejs increasing productivity using vscode integration pattern macro message channel message endpoint message pattern message router message translator messaging mfa offline action processing offline actions in struts pipes and filters PRG in struts react Steam struts System Emulator threads in struts utilities vscode vscode customization vscode extensions vscode productivity extensions xquery xquery 1.0 xquery design principles

Recent Posts

  • 15+ VSCode Extensions To Improve Your Productivity
  • Productivity and Quality Extensions for ReactJS in VSCode..
  • My goto VSCode plugins for 2022…
  • How to enable MFA for your application in Node.JS?
  • Structuring Express Application – How I do it?

Categories

  • Building APIs (8)
  • Building Mobile Apps (1)
  • Building Web Apps (7)
  • Coding Challenges (3)
  • Extensions (1)
  • Fullstack (6)
  • Patterns (8)
  • Tips & Tricks (41)
  • Uncategorized (43)
  • VSCode (2)

Tags

2022 vscode extensions Abstract Factory alienware amazing vscode extensions apple challenges coding coding-challenges Design Patterns dota2 dota2 items dynamic web service call dynamic webservice invocation enterprise integration express flex helpful vscode extensions how to implement mfa in nodejs increasing productivity using vscode integration pattern macro message channel message endpoint message pattern message router message translator messaging mfa offline action processing offline actions in struts pipes and filters PRG in struts react Steam struts System Emulator threads in struts utilities vscode vscode customization vscode extensions vscode productivity extensions xquery xquery 1.0 xquery design principles

Archives

  • August 2023 (1)
  • March 2022 (1)
  • February 2022 (1)
  • November 2020 (1)
  • April 2020 (2)
  • May 2019 (1)
  • April 2019 (1)
  • March 2019 (1)
  • December 2018 (1)
  • July 2018 (4)
  • June 2018 (3)
  • March 2018 (1)
  • May 2016 (1)
  • December 2015 (1)
  • May 2015 (1)
  • April 2015 (2)
  • March 2015 (1)
  • December 2014 (2)
  • November 2014 (2)
  • October 2014 (1)
  • August 2014 (2)
  • July 2014 (1)
  • April 2014 (1)
  • March 2014 (1)
  • February 2014 (2)
  • January 2014 (1)
  • December 2013 (4)
  • November 2013 (4)
  • October 2013 (3)
  • September 2013 (4)
  • August 2013 (2)
  • July 2013 (5)
  • June 2013 (9)
  • May 2013 (6)
  • April 2013 (2)
  • March 2013 (2)
  • January 2013 (1)
  • November 2012 (2)
  • HOME
  • BLOG
  • CONTACT ME
  • DISCLAIMER & COPYRIGHTS

Copyright © 2025

%d