您的位置:首页 > Web前端 > JavaScript

jsp学习杂记

2009-02-13 10:53 169 查看
“Include”指令可以把你的内容分成更多可管理的元素,比如包括一个普通页面页眉或页脚的元素。包含的网页可以是一个固定的HTML
页面或更多的JSP内容:
<%@ include file="filename.jsp" %>

在本页面显示"filename.jsp"里的内容。

include用来在主JSP文件中调用本地的一个其他文件,通常是一些版权信息啦,脚本语言啦等其他任何你想在其他文件中重复使用的代码。在这个例子中就是调用了一个图片其实。

插入图片:
<img src="struts-power.gif" alt="Powered by
Struts">
图片放在当前目录下!

session用法:

在session中存放数据用request.getParameter("username")获取username(文本框)中的数据,存放在名为theName的地方;

<%
String name =
request.getParameter("username");
session.setAttribute("theName",name);
String
eMail =
request.getParameter("email");
session.setAttribute("Email",eMail);
String
telNum =
request.getParameter("telnum");
session.setAttribute("TelNum",telNum);
%>

读取session中的数据:

用session.getAttribute("theName")读取存放在theName中的数据!

<%=
session.getAttribute("theName")
%>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: