for example i made three jsp
file like this
example1.jsp
<%
HashMap<String, String> map = new HashMap<String, String>();
map.put(test1);
map.put(test2);
%>
-
example2.jsp
<%
out.print(map.get(test1));
%>
-
example3.jsp
<%
out.print(map.get(test2));
%>
i want to using variable map declaration at example1.jsp
and
using at exmple2.jsp
and exmaple3.jsp
how can i using variable like this?
You can use <%@include file="example2.jsp" %>
and <%@include file="example3.jsp" %>
in your first jsp. Basically what you are doing is you are statically including the two jsp files. The variables declared in first jsp will be visible in second and third jsp.
If you do a jsp include then the variables define in first jsp will not be visible in second and third jsp due to the fact that it is a dynamic include
See this more details What is the difference between <jsp:include page = ... > and <%@ include file = ... >?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.