• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to show map of maps in jsp,struts

 
Tanu Gulati
Ranch Hand
Posts: 113
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got a problem where I have to iterate and show HashMap(<HashMap>,string) on a jsp page. I am using another HashMap as a key(as per my business scenario)

can anyone help me understand how I can achieve it through JSP or struts.

 
Rajkamal Pillai
Ranch Hand
Posts: 445
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This is an earlier post I found on The Ranch.
Iterate Map through Struts

Tweak according to your situation. And feel free to post any queries...

Cheers,
Raj.
 
Tanu Gulati
Ranch Hand
Posts: 113
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is an earlier post I found on The Ranch.
Iterate Map through Struts


I actually got this before posting on codeRanch but in my case the problem is little different I have a HashMap(say hashmap1) which contains another HashMap (say hashmap 2) , i want to get the values of hashmap2 as a group and print against a value.


 
Rajkamal Pillai
Ranch Hand
Posts: 445
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You can use the custom tags to iterate through each map and embed all of this within the correct HTML tags to get the desired display, correct?

I do not see the problem you face...

Cheers,
Raj.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Custom tags are not necessary. The JSTL and EL are perfectly able to deal with Maps of any type.
 
Rajkamal Pillai
Ranch Hand
Posts: 445
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I mentioned "custom tags" as Struts relies on a few by default.

Since you mentioned JSTL and EL:

I have seen that they do not cause errors on the web page but apart from that is there any noticeable performance degradation?

Cheers,
Raj.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compared to what?
 
Rajkamal Pillai
Ranch Hand
Posts: 445
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear,

I was trying to compare the performance, Custom tags vs JSTL/EL.

Cheers,
Raj.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why should there be a performance difference? The JSTL and other custom tags are based on the same tag mechanism.

The EL is built into the JSP engine so it's likely highly optimized.
 
Rajkamal Pillai
Ranch Hand
Posts: 445
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thank you, Bear.

I felt that using a Custom Tag would involve invoking the tag handler and hence added a layer altogether which might cause some (slight) overhead.

Now as EL has been built into the JSP engine and this could probably eliminate this overhead.

What I was trying to figure out is the best practices when it comes to usage of Custom Tags.

Cheers,
Raj.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Best practice is to use the JSTL for what it does and only use other custom tags for things that the JSTL does not provide.
 
Rajkamal Pillai
Ranch Hand
Posts: 445
1
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thank you so much Bear.

This was a doubt I have been having for quite a while.

Thanks,
Raj.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic