Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to prevent "if-scriptlet"-bloated jsps?

843841Apr 10 2003 — edited Apr 13 2003
I'm worried that my jsps will be bolated with "if-scriptlets" as a result of my access control system. ie.
...
<td><% if(userBean.isModerator()) { %>
<a href="/servlet/removePost?ID=1212">Remove this post</a>
<% }
else
{ %>
&nbsp;
<% } %>
</td>
...
jleech, is this what you ment with the dynamic menus thing? that I should do that kind of checking in a filter and just store the resulting in variable somewhere that is accessible from the jsp.
filter:
...
String removePostString = "";
if(userBean.isModerator())
  removePostString = "<a href=\"/servlet/removePost?ID=1212\">Remove this post</a>";
stringsBean.setRemovePost(RemovePostString);
...
jsp:
...
<td>
<jsp:getProperty name="stringsBean" property="removePost"/>
</td>
...
The last sure looks cleaner to me... I guess the different strings could be stored in a file somewhere...

Is this a good idea?

/Niklas Andersson
Sweden
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 11 2003
Added on Apr 10 2003
4 comments
43 views