Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing a hashmap to a tag file

 
Nauman Hasan
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,

I am using Tag Files with JSP and ran into a puzzling issue. Just as background I am using JDK 1.6 and Apache Tomcat 6.0.33. In short the same code in tag seems to be causing a exception. So what I am wondering is if there is translation occuring in between the JSP and Tag file (even with tag attribute is marked as dynamic). Thanks for your help!

In the main JSP page I have the following (snippets)


The output is


In the tag file I have following code snippets


If don't put in the last forEach then I get


Otherwise there is an exception


Any help would be appreciated.

~Nauman
 
Stefan Evans
Bartender
Posts: 1721
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are missing a vital element in the declaration of the attribute in your tag file:



Unless you specify the type, it assumes the attribute you are declaring is a String.
Doing a <c:forEach> over a String is valid (assumes it is a comma separated list of strings, and so returns each element as a String)
Hence why the first loop 'works' but the second one failed.
 
Nauman Hasan
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You sir and fabulous!

Thanks it works now

~Nauman
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic