哪位大虾能提供一个JSP内置Application对象应用的例子?

adailee 2002-02-26 03:37:57
我手里只有这样一个简单描述:

对象:Application
类型:javax.servlet.ServletContext
描述:Servler的环境通过调用getServletConfig().getContext()方法获得。
作用域:Application(整个Web应用程序运行期)

请问,如何创建使用这个对象?
...全文
168 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
adailee 2002-02-26
  • 打赏
  • 举报
回复
谢谢。
111222 2002-02-26
  • 打赏
  • 举报
回复

只需要人民币20元,

你就可以获得本灌水机的程序和Visual C++源代码,

并获得永久性技术支持。

还等什么?灌水等着你!

就在今夜!元宵佳节!

(可怜我信誉)
yanchang 2002-02-26
  • 打赏
  • 举报
回复
<%
application.setAttribute("name","value");
%>
<%
String s = (String)application.getAttribute("name");
%>
zxp_net 2002-02-26
  • 打赏
  • 举报
回复
i have
zxp_net 2002-02-26
  • 打赏
  • 举报
回复
liuyan1.jsp
<%
String temp=new String();
temp=(String)application.getAttribute("num");
if(temp==null){
application.setAttribute("num","0");
}
%>
<html>
<head>
<title>留言板</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<p> </p>
<p align="center"><b><font size="5" color="#FF6633">留 言 板</font></b></p>
<hr size="1">
<form name="form1" method="post" action="liuyan2.jsp">
<table width="60%" border="0" cellspacing="1" cellpadding="3" align="center" bgcolor="#999999">
<tr bgcolor="#FFFFFF">
<td width="20%">留言作者:</td>
<td width="80%">
<input type="text" name="txtaut">
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="20%">留言标题:</td>
<td width="80%">
<input type="text" name="txttit">
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="20%">留言内容:</td>
<td width="80%"> </td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="20%"> </td>
<td width="80%">
<textarea name="txtart" cols="45" rows="7"></textarea>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="20%"> </td>
<td width="80%"> </td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="2">
<div align="center">
<input type="submit" name="cmdok" value="添加到留言薄">
<input type="reset" name="cmdreset" value="重新填写留言">
<input type="button" name="cmdread" value="查看所有留言"
onClick="MM_openBrWindow('liuyan3.jsp'),'','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,width=400,height=400'">
</div>
</td>
</tr>
</table>
</form>
<p> </p>
</body>
</html>


liuyan2.jsp
<html>
<head>
<title>留言板</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<p> </p>
<p align="center"><b><font size="5" color="#FF6633">留 言 板</font></b></p>
<hr size="1">
<%
int n;
String temp=new String();
String temp1=new String();
String temp2=new String();
String temp3=new String();
temp1=request.getParameter("txttit");
temp2=request.getParameter("txtaut");
temp3=request.getParameter("txtart");
n=temp1.length()*temp2.length()*temp3.length();
if(n!=0){
temp=(String)application.getAttribute("num");
n=Integer.parseInt(temp);
n=n+1;
temp=temp.valueOf(n);
application.setAttribute("num",temp);
application.setAttribute("tit"+temp,temp1);
application.setAttribute("aut"+temp,temp2);
application.setAttribute("art"+temp,temp3);
%>
<p> </p>
<p align="center">留言成功!</p>
<%
}
else{
%>
<p align="center"><font color="#FF0000">不添加作者、标题和内容,留言失败!</font></p>
<%
}
%>
<p align="center"><a href="liuyan1.jsp">返回首页</a> </p>
</body>
</html>


liuyan3.jsp
<html>
<head>
<title>留言板</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<p> </p>
<p align="center"><b><font size="5" color="#FF6633">留 言 板</font></b></p>
<hr size="1">
<%
int n;
String temp=new String();
String temp1=new String();
String temp2=new String();
String temp3=new String();
temp=(String)application.getAttribute("num");
n=Integer.parseInt(temp);
if(n==0){
%>
<p> </p>
<p align="center">目前还没有文章!</p>
<%
}
else{
%>
<table width="60%" border="1" cellspacing="0" cellpadding="5" align="center" bordercolor="#999999">
<%
int i;
for(i=1;i<=n;i++){
temp=temp.valueOf(i);
temp1=(String)application.getAttribute("tit"+temp);
temp2=(String)application.getAttribute("aut"+temp);
temp3=(String)application.getAttribute("art"+temp);
%>
<tr>
<td bgcolor="#CCFFCC" height="27"><b><%=temp%>.标题:<%=temp1%>作者:<%=temp2%></b></td>
</tr>
<tr>
<td><%=temp3%></td>
</tr>
<%
}
}
%>
</table>
<p align="center"> </p>
</body>
</html>

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧