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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:09:01+00:00 2026-05-20T11:09:01+00:00

I’m trying to write a Struts2 tag to my JSP from a custom tag.

  • 0

I’m trying to write a Struts2 tag to my JSP from a custom tag. I have the code below. Is this actually possible, or is there something about the JSP life cycle that makes this impossible? If it is impossible, is there another way to do what I’m trying to do?

        while (iterator.hasNext()) {
            Bulletin bulletin = (Bulletin) iterator.next();
            if (bulletin.isApproved()) {
                out.println("<s:url value=\"GetSingleBulletin\">");
                out.println("<s:param name=\"id\" " 
                        + "value=\"%{" + bulletin.getId()+ "}\" />");
                out.println(bulletin.getName() + " -- " + bulletin.getSubject() 
                        + " " + bulletin.getDate());
                out.println("</s:url>");
                out.println("<br><br>");
            }
        }
  • 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-20T11:09:01+00:00Added an answer on May 20, 2026 at 11:09 am

    Tags are resolved as part of the “translation phase” that converts a JSP to a servlet. By emitting other tags in your tag, you are assuming a “2nd pass” translation, which does not happen. So it’s fundamentally a bad idea.

    Instead, I would suggest just emitting the equivalent HTML (really just a URL with parameters, given your code above). Assuming your problem is no more complex than what you describe above, this seems like the simplest approach. In fact, even if you could emit tags, I don’t see a very convincing case here for why tags would be better than raw HTML anyway. JSP taglibs are supposed to facilitate automation and less code where possible; less code reduces errors and makes JSPs more maintainable. But your case above is not one that screams out for “must use tags”.

    Alternatively, if you would really prefer to use the tags you have in your custom tag above, or you would be willing to eliminate your taglib altogether, you could write the above Java code in a scriptlet and intersperse your use of the other struts tags in between that scriptlet code. So, something like:

    <%
            while (iterator.hasNext()) {
                Bulletin bulletin = (Bulletin) iterator.next();
                if (bulletin.isApproved()) {
    %>
                    <s:url value="GetSingleBulletin">
    etc.
    
    <%
                }
            }
    %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a bunch of posts stored in text files formatted in yaml/textile (from

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.