📄 newpost_0002ejsp_jsp.java
字号:
import java.sql.*;
import java.util.*;
import java.text.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import org.apache.jasper.runtime.*;
public class newpost_0002ejsp_jsp extends HttpJspBase {
static {
}
public newpost_0002ejsp_jsp( ) {
}
private static boolean _jspx_inited = false;
public final void _jspx_init() throws org.apache.jasper.runtime.JspException {
}
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;
String _value = null;
try {
if (_jspx_inited == false) {
synchronized (this) {
if (_jspx_inited == false) {
_jspx_init();
_jspx_inited = true;
}
}
}
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html; charset=GBK");
pageContext = _jspxFactory.getPageContext(this, request, response,
"", true, 8192, true);
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
// HTML // begin [file="/newpost.jsp";from=(0,48);to=(1,0)]
out.write("\r\n");
// end
// HTML // begin [file="/newpost.jsp";from=(1,31);to=(2,0)]
out.write("\r\n");
// end
// HTML // begin [file="/newpost.jsp";from=(2,31);to=(3,0)]
out.write("\r\n");
// end
// HTML // begin [file="/newpost.jsp";from=(3,31);to=(14,0)]
out.write("\r\n<html>\r\n<head>\r\n<title>发帖子页面</title>\r\n<style type=\"text/css\">\r\n<!--\r\n.style1 {font-size: 36px}\r\n-->\r\n</style>\r\n</head>\r\n<body bgcolor=\"#ffffff\">\r\n");
// end
// begin [file="/newpost.jsp";from=(14,0);to=(14,30)]
{
String _jspx_qStr = "";
JspRuntimeLibrary.include(request, response, "logo.jsp" + _jspx_qStr, out, false);
if ("true".equals(request.getAttribute("javax.servlet.forward.seen")))
return;
}
// end
// HTML // begin [file="/newpost.jsp";from=(14,30);to=(24,0)]
out.write("\r\n<table width=\"90%\" border=\"0\" align=\"center\" borderColor=\"#F0F0F0\" bgcolor=\"#ffffff\">\r\n<form action='' method=\"post\">\r\n<tr><td>标题:</td>\r\n<td><input type=\"text\" name=\"head\" size=\"50\"/></td></tr>\r\n<tr><td>内容:</td>\r\n<td><textarea rows=\"8\" name=\"content\" cols=\"100\"></textarea></td></tr>\r\n<tr><td><input type=\"submit\" value=\"发帖\"/></td></tr>\r\n</form>\r\n</table>\r\n");
// end
// begin [file="/newpost.jsp";from=(24,2);to=(61,0)]
Connection conn;
PreparedStatement ps;
ResultSet rs;
String date=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
String head=request.getParameter("head");
String content=request.getParameter("content");
Object username=session.getAttribute("username");
String postip=request.getRemoteAddr();
int forcumid;
int userid;
if(username!=null){
if(head!=null&&content!=null){
forcumid=Integer.parseInt(request.getParameter("forcumid"));
userid=Integer.parseInt((String)session.getAttribute("userid"));
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("jdbc:odbc:bbs","","");
String sql="insert into post(head,content,forcumid,userid,post_time,post_ip) values(?,?,?,?,?,?)";
ps=conn.prepareStatement(sql);
ps.setString(1,head);
ps.setString(2,content);
ps.setInt(3,forcumid);
ps.setInt(4,userid);
ps.setString(5,date);
ps.setString(6,postip);
ps.executeUpdate();
conn.close();
this.getServletContext().getRequestDispatcher("/forcum.jsp?forcumid="+forcumid).forward(request,response);
//response.sendRedirect("forcum.jsp?forcumid="+forcumid);
}
}else{
out.println("<script>alert('请先登录!');this.location.href='login.jsp';</script>");
}
// end
// HTML // begin [file="/newpost.jsp";from=(61,2);to=(64,0)]
out.write("\r\n</body>\r\n</html>\r\n");
// end
} catch (Throwable t) {
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (pageContext != null) pageContext.handlePageException(t);
} finally {
if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -