In my a.jsp file:
<html>
<body>
<%
out.print("<my:login error=\"${Error}\"/>"); // It doesn't work :(
%>
<my:login error="${Error}"/> // It only works if I put it here
</body>
</html>
Can anybody tell me where I were wrong? Thanks.
In the first approach you’re printing the tag as plain text and thus it becomes part of HTML directly. Truly it won’t work since the webbrowser does not parse JSP tags. Using scriptlets is also discouraged anyway.
The second is the correct approach. If your sole functional requirement is to inline the tag conditionally, then nest it inside a JSTL
<c:if>insteador something.