开发者社区> 问答> 正文

用application对象实现一个简单的聊天室 请教大侠怎么写:报错

<body>
<%
String txt="我说:";
String str="";
try{
request.setCharacterEncoding("GB18030");
str=txt+request.getParameter("in")+"<br/>";
txt=application.getAttribute("str").toString();
}catch(Exception e){
txt="";
str="";
}finally{
application.setAttribute("str",(txt+str));
}
%>
<form action="test7.jsp">
<table border="1">
<tr height="200px">
<td>
<%=txt+str %>
</td>
</tr>
<tr height="40px">
<td>
<input type="text" name="in"/>
<input type="submit" value="发送"/>
</td>
</tr>
</table>
</form>
</body>
<body>
<%
String txt="我说:";
String str="";
try{
request.setCharacterEncoding("GB18030");
str=txt+request.getParameter("in")+"<br/>";
txt=application.getAttribute("str").toString();
}catch(Exception e){
txt="";
str="";
}finally{
application.setAttribute("str",(txt+str));
}
%>
<form action="test7.jsp">
<table border="1">
<tr height="200px">
<td>
<%=txt+str %>
</td>
</tr>
<tr height="40px">
<td>
<input type="text" name="in"/>
<input type="submit" value="发送"/>
</td>
</tr>
</table>
</form>
</body>
<body>
<%
String txt="我说:";
String str="";
try{
request.setCharacterEncoding("GB18030");
str=txt+request.getParameter("in")+"<br/>";
txt=application.getAttribute("str").toString();
}catch(Exception e){
txt="";
str="";
}finally{
application.setAttribute("str",(txt+str));
}
%>
<form action="test7.jsp">
<table border="1">
<tr height="200px">
<td>
<%=txt+str %>
</td>
</tr>
<tr height="40px">
<td>
<input type="text" name="in"/>
<input type="submit" value="发送"/>
</td>
</tr>
</table>
</form>
</body>

展开
收起
kun坤 2020-06-09 12:16:47 451 0
1 条回答
写回答
取消 提交回答
  • 好牛逼的代码···· 应该是书上的例子吧,或者是作业。。。。。。 我记得N年前看过一本JSP入门,好像有这个东西######嗯 是作业 ... 我是新手 .. 不知道咋弄了 .. 麻烦大侠指点下 ..######嗯  .. 是作业 ..不知道咋写了 我是新手.

    2020-06-09 12:16:54
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载