Can a JSP tag access the JSP page instance that contains it?
If a page contains JSP-tag, can the tag access the instance of the JSP class that it is being used in?
Assume we have the following JSP:
<%
String someVariable;
%>
Hello <ns:开发者_JAVA百科someTag />
Can someTag's class access the value of someVariable?
No, because the usage of tags and scriptlets should not be mixed.
If you define the 'variable' as a request attribute, with jstl: <c:set var="someVar" value"foo" />
, then it is accessible via the pageContext
in the Tag class.
精彩评论