For example, a user will be rendered throughout my application as
<div class="user">
<p class="username">${user.name}</p>
<p class="karma">${user.karma}</p>
<img src="/users/${user.id}"/>
</div>
How can I reuse this code block?
Note - my code is running within a tag, so I can't use tags for this (or any JSP) otherwise I get a Scripting elements are disallowed here
error.
Edit
I'm trying to use a tag file, but getting PropertyNotFoundException.
This is my tag file called 'user.tag':
<%@tag description="User" pageEncoding="UTF-8" %>
<a href="../user/showUser.do?userId=${user.id}">
<p>${user.name}</p>
<img class='avatar' src='${user.avatarUrl}' alt=""/>
</a>
And usage inside a jsp:
Where job.poster is a java bean with id
, name
, and avatarUrl
properties.
If I add
<%@attribute name="user" %>
to the tag file, then I get an exception
Property 'id' not found on type java.lang.String