Change html content with jstl or scriptlet
I know that you can use javascript inner html to change the content of the HTML code inside a <div>
tag. But is there anyone here who know of a way to change the content of HTML using other lang开发者_如何学Gouages such as JSTL or scriptlets?
I assume that you're fully aware that Java/JSP/JSTL runs at webserver and produces HTML/CSS/JS and that HTML/CSS/JS runs at the webbrowser. Thus, Java/JSP/JSTL has totally no notion of the client side HTML DOM tree like as JS has access to by the document
object. But Java/JSP/JSTL can be used to control the rendering of the HTML/CSS/JS output.
You could use JSTL and/or EL to conditionally display blocks of HTML/CSS/JS. E.g.
<div>
<c:if test="${condition1}">
<p>This block will only be rendered when condition1 evaluates true.</p>
</c:if>
<c:if test="${condition2}">
<p>This block will only be rendered when condition2 evaluates true.</p>
</c:if>
</div>
Using scriptlets is discouraged since JSP 2.0 (2003). So don't even think about it.
精彩评论