1. Javascript访问JSP变量
<% String some_jsp_var = "This is a java variable in a JSP."; %> <script language="Javascript"> alert("<%=some_jsp_var%>"); </script>
2. jsp 访问JSTL变量
能访问吗?
3. JSTL 访问JSP变量
<%
String[] names= {
"Tom"
,
"Dick"
,
"Harry"
,
"Matthew"
,
"Mark"
,
"Luke"
,
"John"
};
pageContext.setAttribute(
"names"
, names);
%>
<c:set var=
"msg"
value=
"The names are:"
/>
<c:forEach var=
"name"
items=
"${names}"
varStatus=
"status"
>
<c:set var=
"msg"
>
<c:out value=
"${msg} ${name}"
/><c:
if
test=
"${not status.last}"
>,</c:
if
>
</c:set>
</c:forEach>
<c:out value=
"${msg}"
/>