Sure. Instead of just stuffing a String comment as the value of the comments Map, put an object that contains all the fields you need to access.
Let's assume you have a database table called users containing the following fields: filename, name, address and comment. You can now create a representation of such a user row in Java by creating a "User" class, for instance like this (index.htt):
<%!
class User {
String name;
String address;
String comment;
public User(String name, String address, String comment) {
this.name = name;
this.address = address;
this.comment = comment;
}
}
%>
Now peek at this demo code that populates a "users" Map object with two users:
<%!
Map users = new HashMap();
users.put("john.jpg", new User("John Doe", "Burbon St", "Don't we just love John Doe"));
users.put("sam.jpg", new User("Sam Nielssen", "West St", "Another fake user"));
%>
In my example, the "users" map replaces the comments map used in the script previously. Now, to refer to the relevant fields of this "users" Map from the slide.htt file, you can do like this:
<%
User user = (User)users.get("sam.jpg"); // In a real world example, "sam.jpg" would be fileName
%>
Now you can insert the field values of this user whereever you like, by writing like this (slide.htt):
<ja:if exists="user">
The user's name is <%= user.name %>, his addresss is <%= user.address %> and he comment is <%= user.comment %>
</ja:if>