This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JSP and the fly likes Passing a hashmap to a tag file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Passing a hashmap to a tag file" Watch "Passing a hashmap to a tag file" New topic
Author

Passing a hashmap to a tag file

Nauman Hasan
Ranch Hand

Joined: Jul 27, 2005
Posts: 34
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

Joined: Jul 06, 2005
Posts: 1018
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

Joined: Jul 27, 2005
Posts: 34
You sir and fabulous!

Thanks it works now

~Nauman
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing a hashmap to a tag file