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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:40:11+00:00 2026-06-13T14:40:11+00:00

I am using JSP tag files to add widgets to my application pages. Is

  • 0

I am using JSP tag files to add “widgets” to my application pages.

Is it possible to have an action associated with a JSP tag file, so it will be populated with dynamic content just like a normal page and then “injected” in some place?

Let’s say I have tag file that I invoke like this: <c:onlinemembers />. It displays the list of online members.
I need to have a way of populating it with dynamic data before it is displayed.

Any suggestions?

  • 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-13T14:40:13+00:00Added an answer on June 13, 2026 at 2:40 pm

    EDIT: as pointed out by Alexandr, this is good on Struts 2.0.x, where Struts integrates Dojo tags. Since Struts 2.1.x, jQuery should be used instead (with similar mechanism).

    All depends on your Struts2 version.


    OR you can use the built-in Struts2/Dojo AJAX feature.

    <head>
        <script type="text/javascript">
          // Scripts executed when loading the JSP:
          function configPage(){
            // Dojo topic function subscribing:
            dojo.event.topic.getTopic("myTopic").subscribe(null, "updateDivFunction");
          }
    
          function updateDivFunction(param1, param2){
            // Get the Div
            var myDiv = dojo.widget.byId("myDynamicDiv"); 
    
            // Set a new href to the AJAX action to call, 
            // which will return a partial JSP (a snippet),
            // as mapped normally in struts.xml...      
            myDiv.href = "loadDynamicDivAjax.do?param1="+param1+"&param2="+param2;
    
            // Force the div to reload with AJAX now.
            resultDiv.refresh();
          }
    
          function updateDivWrapper(param1, param2){
            // Publishing the topic now, will invoke the 
            // "updateDivFunction" set in configPage()...
            dojo.event.topic.publish("myTopic", param1, param2);
          }
    
    
        </script>
    </head>
    
    <body onload="javascript:configPage();">
        <h1>My main JSP page</h1>
    
        <br/><br/>
    
        <s:div id="myDynamicDiv" theme="ajax" 
               loadingText="Loading..." 
               errorText="Errors occurred...">
        </s:div>
    
        <br/>
    
        <span>
            Click below links to load the DIV with DOJO 
            through an AJAX call, and different parameters.
        </span>
    
        <br/><br/>
    
        <a href="javascript:updateDivWrapper('1','2')">
            Update with param1=1 and param2=2
        </a>
    
        <br/><br/>
    
        <a href="javascript:updateDivWrapper('8','9')">
            Update with param1=8 and param2=9
        </a>
    </body>
    

    in Struts.xml you should map loadDynamicDivAjaxAction to returning a normal JSP snippet as a result. That’s it…

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

Sidebar

Related Questions

I have problem using jstl tag <c:if> in jsp file. Basically I should make
In a web project using jsp, I have following requirement Upload a file (say
My web application is written using jsp/javascripts. Backend Java. Have managed to implement the
How can I upload files to server using JSP/Servlet? I tried this: <form action="upload"
I'm working on a web application using JSP/Servlets, etc. And I have a lot
I am using Tiles within my web-application. I have a standard-layout (standard.jsp) within the
This is my jsp file body tag. <body> <jsp:plugin type=applet code=SApplet.class codebase=C:\Program Files\apache-tomcat-6.0.18\webapps\testweb\WEB-INF\classes width=400
How can I add jspf file to jsp page via custom tag? In the
We have an application that using the basic JSP/servlet that all text currently in
I am passing dynamic values with href tag in dynamically generated jnlp using jsp.

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.