I know that using JSP scripts is generally frowned upon, so I wonder if there is a more elegant way to achieve what I'm trying to do. I mainly create a view, and depending on certain situations in the domain model, I process different HTML.
For example, consider a scenario in which a user may be in a role. And such a method is defined in the user model class:
public boolean isInRole(String roleName) {
}
And then we have a JSP as shown below:
<%
User user = (User)request.getAttribute("user");
%>
<% if (user.isInRole("admin") { %>
<% } %>
As far as I know, this cannot be done using JSTL / EL. Does using scripts sound like a good idea here? Or is there another approach I have to take?
Thanks for any suggestions.
source