Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get a dynamic href tag with JSP with a value from java class

I'm able to get the href tag dynamic now, but now unable to acccess the HashMap from my MMTUtil which gives mw the value corresponding to my Key(objectName)gUnable to think of any solution I have imported the class in the JSP thats how far I'm able to go

MMTUtil.getDomainComboDocumentationMap().get(objectName);

where objectName is a key and I need to get the value out of it So that it can be used in href

What I have tried: I think this might not work

<%
UMRDocumentationDTO documentationDTO = new UMRDocumentationDTO();
String objectName = documentationDTO.getId().getObjectName();  //getting error here and the debgger goes directly at the end of the page
String tc = MMTUtil.getDomainComboDocumentationMap().get(objectName);
%>

can we try something like this?

for (Map.Entry entry : MMTUtil.getDomainDocumentationMap().entrySet()){
        Object documentationLink =  entry.getValue();
}



<td><a href="<%=documentationLink%>" target="_blank"
id="domainName_<s:property value="#rowstatus.index"/>"><s:property
value="domainName" /></a>

I'm unable to access the Value from my Map in Jsp any error?

public class MMTUtil
{

private static Map<String, String> domainDocumentationMap             = null;

static
{
    domainDocumentationMap = new HashMap<String, String>();
    domainComboDocumentationMap =new HashMap<String, String>();
}

public static Map<String, String> getDomainDocumentationMap() {
    return domainDocumentationMap;
}

public static void setDomainDocumentationMap(String objectName, String documentationLink) {
    MMTUtil.domainDocumentationMap.put(objectName, documentationLink);

//        for(Map.Entry entry:MMTUtil.domainDocumentationMap.entrySet()){
//            System.out.println(entry.getKey() + " " + entry.getValue());
//        }
    }
like image 671
user7474502 Avatar asked Jan 22 '26 05:01

user7474502


1 Answers

You need to use expression tag href="<%=tc%>"

If you are getting the correct path in tc.

I hope it will help you.

like image 50
Raj Rusia Avatar answered Jan 23 '26 20:01

Raj Rusia