开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜