📄 write_jsp.java
字号:
package org.apache.jsp.message;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.util.*;
public final class write_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent {
//\u4E00\u4E9B\u5E38\u7528\u7684\u51FD\u6570
int maxMessage=100;//\u670D\u52A1\u5668\u8BB0\u5F55\u7684\u6700\u5927\u4FE1\u606F\u6570
int lessMessage=50;//\u8D85\u8FC7\u6700\u5927\u4FE1\u606F\u6570\u540E\uFF0C\u4FDD\u7559\u7684\u4FE1\u606F\u6570
public String getStr(String str)//\u8F6C\u6362\u5B57\u7B26\uFF0C\u907F\u514D\u8F93\u51FA\u4E71\u7801
{
try {
String temp_p=str;
byte[] temp_t=temp_p.getBytes("ISO8859-1");
String temp=new String(temp_t);
return temp;
} catch(Exception e) {
return null;
}
}
public void addToChatmsg(String msg){//\u589E\u52A0\u4E00\u6761\u804A\u5929\u8BB0\u5F55
Vector chatmsg;
if(getServletContext().getAttribute("chatmsg")==null){
chatmsg=new Vector();
} else{
chatmsg=(Vector)getServletContext().getAttribute("chatmsg");
}
chatmsg.addElement(msg);
if(chatmsg.size()>maxMessage){
for(int j=chatmsg.size()-lessMessage-1;j>=0;j--)
chatmsg.removeElementAt(j);
}
getServletContext().setAttribute("chatmsg",chatmsg);
}
public boolean isOnline(String username){//\u5224\u65AD\u7528\u6237\u662F\u5426\u5728\u7EBF
if(getServletContext().getAttribute(username)==null){
return false;
}
return true;
}
String writeto=null;
String title=null;
private static java.util.Vector _jspx_dependants;
static {
_jspx_dependants = new java.util.Vector(1);
_jspx_dependants.add("/message/../Common.jsp");
}
public java.util.List getDependants() {
return _jspx_dependants;
}
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException {
JspFactory _jspxFactory = null;
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;
PageContext _jspx_page_context = null;
try {
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html; charset=gb2312");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
out.write('\r');
out.write('\n');
out.write('\r');
out.write('\n');
out.write('\r');
out.write('\n');
chatweb.conn db = null;
synchronized (_jspx_page_context) {
db = (chatweb.conn) _jspx_page_context.getAttribute("db", PageContext.PAGE_SCOPE);
if (db == null){
db = new chatweb.conn();
_jspx_page_context.setAttribute("db", db, PageContext.PAGE_SCOPE);
}
}
out.write("\r\n");
out.write("<html>\r\n");
out.write("<head>\r\n");
out.write("<title>\r\n");
out.write("write\r\n");
out.write("</title>\r\n");
out.write("<link href=\"../chat.css\" rel=\"stylesheet\" type=\"text/css\">\r\n");
out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">\r\n");
out.write("<script language=\"JavaScript\" type=\"text/JavaScript\">\r\n");
out.write("<!--\r\n");
out.write("function MM_goToURL() { //v3.0\r\n");
out.write(" var i, args=MM_goToURL.arguments; document.MM_returnValue = false;\r\n");
out.write(" for (i=0; i<(args.length-1); i+=2) eval(args[i]+\".location='\"+args[i+1]+\"'\");\r\n");
out.write("}\r\n");
out.write("//-->\r\n");
out.write("</script>\r\n");
out.write("</head>\r\n");
out.write("<body bgcolor=\"#FFF7DD\">\r\n");
out.write('\r');
out.write('\n');
if(request.getMethod().toUpperCase().equals("POST")){
String toUser=request.getParameter("receiver");
String fromUser=session.getAttribute("username").toString();
String ti=request.getParameter("ttitle");
ti=new String(ti.replaceAll("<","<"));
ti=new String(ti.replaceAll(">",">"));
String content=request.getParameter("content");
content=new String(content.replaceAll("<","<"));
content=new String(content.replaceAll(">",">"));
if(db.addMsg(fromUser,toUser,content,ti)){
out.write("\r\n");
out.write("\t\t<script language=\"JavaScript\" type=\"text/JavaScript\">\r\n");
out.write("\t\twindow.alert(\"信息发送成功\");\r\n");
out.write("\t\tlocation.href=\"message.jsp\";\r\n");
out.write("\t\t</script>\r\n");
out.write("\t\t");
}
else{
out.write("\r\n");
out.write("\t<script language=\"JavaScript\" type=\"text/JavaScript\">\r\n");
out.write("\twindow.alert(\"发送失败,请检查接收方\");\r\n");
out.write("\t</script>\r\n");
out.write("\t");
}
}
if(request.getMethod().toUpperCase().equals("GET")){
writeto=getStr(request.getParameter("writeto"));
title="Re: "+getStr(request.getParameter("title"));
}
if(writeto==null){
writeto=new String("");
title=new String("");
}
out.write("\r\n");
out.write("<div align=\"center\">\r\n");
out.write(" <form name=\"form1\" method=\"post\" action=\"\">\r\n");
out.write(" <table width=\"80%\" border=\"0\" cellspacing=\"1\" class=\"mytable\">\r\n");
out.write(" <tr bgcolor=\"#FFF7DD\">\r\n");
out.write(" <td nowrap>\r\n");
out.write(" <div align=\"left\">主题:</div></td>\r\n");
out.write(" <td width=\"90%\">\r\n");
out.write(" <input name=\"ttitle\" type=\"text\" id=\"title\" value=\"");
out.print(title);
out.write("\">\r\n");
out.write(" </td>\r\n");
out.write(" </tr>\r\n");
out.write(" <tr bgcolor=\"#FFF7DD\">\r\n");
out.write(" <td nowrap>\r\n");
out.write(" <div align=\"left\">接收人:</div></td>\r\n");
out.write(" <td>\r\n");
out.write(" <input name=\"receiver\" type=\"text\" id=\"receiver\" value=\"");
out.print(writeto);
out.write("\"></td>\r\n");
out.write(" </tr>\r\n");
out.write(" <tr bgcolor=\"#FFF7DD\">\r\n");
out.write(" <td nowrap>\r\n");
out.write(" <div align=\"left\">内容:</div></td>\r\n");
out.write(" <td>\r\n");
out.write(" <textarea name=\"content\" cols=\"50\" rows=\"6\" id=\"content\"></textarea></td>\r\n");
out.write(" </tr>\r\n");
out.write(" <tr bgcolor=\"#FFF7DD\">\r\n");
out.write(" <td colspan=\"2\" nowrap>\r\n");
out.write(" <div align=\"center\">\r\n");
out.write(" <input type=\"submit\" name=\"Submit\" value=\"提交\">\r\n");
out.write(" <input type=\"reset\" name=\"Submit3\" value=\"重置\">\r\n");
out.write(" <input name=\"Submit2\" type=\"button\" onClick=\"MM_goToURL('parent','message.jsp');return document.MM_returnValue\" value=\"取消\">\r\n");
out.write(" </div></td>\r\n");
out.write(" </tr>\r\n");
out.write(" </table>\r\n");
out.write(" </form>\r\n");
out.write("</div>\r\n");
out.write("</body>\r\n");
out.write("</html>\r\n");
} catch (Throwable t) {
if (!(t instanceof SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
}
} finally {
if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -