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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:11:05+00:00 2026-05-16T05:11:05+00:00

I am trying to get my page to link to a certain URL that

  • 0

I am trying to get my page to link to a certain URL that is stored in a HashMap (the key is some name, and the value is the URL I want to link to). I’m not very good at describing this, but here is my code:

For the JSP page:

<table>
  <s:iterator value="dependenciesList" id="dependency">
    <tr><td>
    <a href="<s:url value="productDocumentationMap.getKey(%{dependency})"/>">
    <s:property value="dependency"/> </a>
    </td></tr>
  </s:iterator> 
  </table>

Note: productDocumentationMap is a HashMap of <String, String>, and dependenciesList is an ArrayList<String>.

For instance, if dependenciesList contains three elements [A, B, C], the first link would link to something like: http:///productDocumentationMap.getKey(A)
but what I want is for the link to be the actual value of

productDocumentationMap.getKey("A");

I know I might be doing something stupid (I’m still new to all this Struts2 business), but is there a way I can get my link to work? Thanks!

  • 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-16T05:11:05+00:00Added an answer on May 16, 2026 at 5:11 am

    In OGNL, you can access a map using “mapName[indexName]”, where indexName is the key you want.

    e.g.

     <a href="<s:url value='productDocumentationMap[#dependency]'/>">
    

    I think this is the right syntax for resolving ‘dependency’ as a variable, instead of as the string ‘dependency’, but this should call ‘getProductDocumentationMap()’, and if it returns a Map object, attempt to lookup the value of the iterator. I assume you really want the value, rather than the key, since ‘dependency’ itself is the key.

    This page gives some example OGNL expressions that you might find helpful as a reference. I find half the time I just end up fiddling with no parenthesis, %{} and/or # until it works. 🙂

    http://www.vaannila.com/struts-2/struts-2-example/struts-2-ognl-expression-language-example-1.html


    For your follow-up question:

    I use this for testing nulls against simple properties and including a section. I imagine it could probably be applied to returned values from maps.

    <s:if test="%{licenseStatusString != null}">
     ... something that uses licenseStatusString
    </s:if>
    <s:else>
     ... optional thing to include if the license status string is null.
    </s:else>
    

    maybe

    <s:if test="%{productDocumentationMap[#dependency] != null}">
    

    Try that and see if it works. Probably some permutation of that.

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

Sidebar

Related Questions

I am trying to gain the link that is on a certain page of
I'm trying to find any links on the page that link to a certain
So I'm trying to get a link to scroll to a certain coordinate (not
I'm trying to get current page url. Here is the code: $url = (!empty($_SERVER['HTTPS']))
Alright, so I'm trying to get a page to load some js at the
What?: I'm trying to get page-to-page link map (matrix) of wikipedia pages by page_id
I am trying to get h=Af?????????? value from reporting link at social networking site.
I'm trying to get an html page to display an XML file formatted with
Trying to get the header to stick to the top of the page -
I'm trying to get the title of a page in an iFrame. I did

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.