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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:30:31+00:00 2026-05-31T15:30:31+00:00

I want to wrap and modify the response to an HTTP request to my

  • 0

I want to wrap and modify the response to an HTTP request to my Java EE/tomcat application. That is, I have a number of Struts 2 actions that generate results, and I’d like to put a front end on them that modifies the response to do things like hide links, etc. Modifying each of the sources is out of the question because of the large number and variety of them.

I know I can write a Servlet Filter that does what I want, but I’d like to build on a standard, well-tested solution rather than re-inventing the wheel. I’ve searched for one, and there are places in the Java EE docs that describe such a beast, but have not been able to find one that I can download.

Edit: There are comments that this is a terrible idea. I’m open to suggestions as to a better one. The situation is that I have a large number of actions out there, written over a long period of time, and there are various systemic modifications that I’d like to do to their output. I don’t want to modify all the actions because that violates DRY (and would be a ton of work). It seems to me that this is exactly what filters are made for – essentially AOP for HTTP responses. Am I thinking wrong?

Edit #2: As to the significance of the change, it’s hard to say. It’s generally not significant in the sense of adding a lot of new content to the page. It’s more scanning the response and making relatively small changes: for example, adding classes to links under certain conditions, injecting small bits of code in various places on the page, or (in the extreme case) clipping out a div that should not appear to the user. I would say the biggest issue is that the system consists of approximately 4000 unique pages, each generated by a separate action and/or view using several different technologies. We can say this system structure stinks, but that’s the reality of life working on a very large, 15 year old piece of software. My other idea is to only implement a filter to do the scanning, and inject modifications in javascript. This does not help in a situation that is truly security-related (i.e. don’t want to let the user even see the content), but it might help in a number of other cases that are done primarily for user convenience. Thanks everybody for the discussion, please keep it coming.

  • 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-31T15:30:32+00:00Added an answer on May 31, 2026 at 3:30 pm

    If your changes can be classified, I recommend using jQuery.
    All you have to do is to add jQuery to your page, select your tags according to your conditions, and then apply what you need to them.

    If you have a layout manager (I believe you must have SiteMesh or Tiles if it is a Struts 2 application), you can just add what you need in your layout templates, and everything will be ok.


    Another solution which comes to my mind is applyable if you have used consistent tag libraries inside your project. For example if you have used <xyz:myLink/> tag all your project, (even if they are Strtus2 standard tags, or ….), you can just re-implement your tags, and then assign them to old names in TLD files.

    I believe a combination of my previous solution (jQuery) and this solution (reimplementing tags) could help you much, and it would be much easier and more perform than parsing the result DOM and recreating it again.


    And one another solution, if your result pages are XHTML (well formed XML), you can use an XSLT transformer to transform your XHTML to another XHTML.

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

Sidebar

Related Questions

I have a data structure that I want to access / modify in different
I want to wrap a piece of code that uses the Windows Impersonation API
I've got a (poorly written) base class that I want to wrap in a
I have items wrapped in wrap panel. I want to move first line of
I have this program that I want other processes to be able to call
I want to wrap the default open method with a wrapper that should also
I want to wrap tags around the usernames in my tweets so that I
I want to wrap each result from one Wcf service in my application in
Suppose I want to wrap code that can throw exceptions with a try-catch block
I've written a class in python that I want to wrap into a .net

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.