📄 index_0002ejsp_jsp.java
字号:
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import org.apache.jasper.runtime.*;
public class index_0002ejsp_jsp extends HttpJspBase {
static {
}
public index_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="/index.jsp";from=(0,48);to=(1,0)]
out.write("\r\n");
// end
// HTML // begin [file="/index.jsp";from=(1,31);to=(10,0)]
out.write("\r\n<html>\r\n<head><title>BBS系统主页</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");
// end
// begin [file="/index.jsp";from=(10,0);to=(10,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="/index.jsp";from=(10,30);to=(11,0)]
out.write("\r\n");
// end
// begin [file="/index.jsp";from=(11,2);to=(25,0)]
Connection conn;
Statement sm;
ResultSet rs;
PreparedStatement loginPS; //!--
ResultSet loginRS;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("jdbc:odbc:bbs","","");
String loginSQL="select * from user where username=? and password=?";
loginPS=conn.prepareStatement(loginSQL);
String username=request.getParameter("username");
String password=request.getParameter("password");
if(username==null && password==null){
// end
// HTML // begin [file="/index.jsp";from=(25,2);to=(38,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>\r\n<td width=\"5%\">用户名</td>\r\n<td width=\"17%\"><input name=\"username\" type=\"text\" size=\"18\"></td>\r\n<td width=\"5%\">密 码</td>\r\n<td width=\"19%\"><input name=\"password\" type=\"password\" size=\"18\"></td>\r\n<td width=\"54%\"><input type=\"submit\" value=\"登录\"></td>\r\n</tr>\r\n</form>\r\n</table>\r\n\r\n");
// end
// begin [file="/index.jsp";from=(38,2);to=(46,70)]
}
if(username!=null&&password!=null){
loginPS.setString(1,username);
loginPS.setString(2,password);
loginRS=loginPS.executeQuery();
if(loginRS.next()){
session.setAttribute("username",username);
session.setAttribute("userid",""+loginRS.getInt("userid"));
// end
// HTML // begin [file="/index.jsp";from=(46,72);to=(48,24)]
out.write("\r\n<table width=\"90%\" border=\"0\" align=\"center\" borderColor=\"#F0F0F0\" bgcolor=\"#ffffff\">\r\n <tr><td align=\"left\"> ");
// end
// begin [file="/index.jsp";from=(48,26);to=(48,87)]
out.print("欢迎"+session.getAttribute("username")+"来到BBS交流社区");
// end
// HTML // begin [file="/index.jsp";from=(48,89);to=(50,29)]
out.write("</td>\r\n <td align=\"right\">\r\n<a href=user_xian.jsp?userid=");
// end
// begin [file="/index.jsp";from=(50,32);to=(50,62)]
out.print(session.getAttribute("userid"));
// end
// HTML // begin [file="/index.jsp";from=(50,64);to=(53,0)]
out.write(">修改个人资料</a>\r\n</td></tr>\r\n</table>\r\n");
// end
// begin [file="/index.jsp";from=(53,2);to=(54,6)]
}else{
// end
// HTML // begin [file="/index.jsp";from=(54,8);to=(55,0)]
out.write("\r\n");
// end
// begin [file="/index.jsp";from=(55,2);to=(60,0)]
out.println("<script>alert('用户名或密码有误,请重新输入!');this.location.href='login.jsp';</script>");
}
loginRS.close();
}
// end
// HTML // begin [file="/index.jsp";from=(60,2);to=(69,0)]
out.write("\r\n<table border=\"0\" width=\"90%\" align=\"center\" borderColor=\"#F0F0F0\" >\r\n<tr align=\"center\" bgcolor=\"#666666\" >\r\n<td width=\"43%\" align=\"left\"> 版块</td>\r\n<td width=\"15%\" align=\"center\">主题</td>\r\n<td width=\"15%\" align=\"center\">贴数</td>\r\n<td width=\"26%\" align=\"center\">最后发表</td>\r\n</tr>\r\n\r\n");
// end
// begin [file="/index.jsp";from=(69,2);to=(82,0)]
String s="select * from forcum";
sm=conn.createStatement();
rs=sm.executeQuery(s);
while(rs.next()){
int id=rs.getInt(1);
String name=rs.getString(2);
String desc=rs.getString(3);
int total_topic=rs.getInt(5);
int total_post=rs.getInt(6);
String last_forcum=rs.getString(7);
//String last_time=rs.getString("8");
// end
// HTML // begin [file="/index.jsp";from=(82,2);to=(84,44)]
out.write("\r\n<tr bgcolor=\"#CCCCCC\">\r\n<td width=\"43%\"><a href=forcum.jsp?forcumid=");
// end
// begin [file="/index.jsp";from=(84,47);to=(84,49)]
out.print(id);
// end
// HTML // begin [file="/index.jsp";from=(84,51);to=(84,52)]
out.write(">");
// end
// begin [file="/index.jsp";from=(84,55);to=(84,59)]
out.print(name);
// end
// HTML // begin [file="/index.jsp";from=(84,61);to=(84,69)]
out.write("</a><br>");
// end
// begin [file="/index.jsp";from=(84,72);to=(84,76)]
out.print(desc);
// end
// HTML // begin [file="/index.jsp";from=(84,78);to=(86,31)]
out.write("\r\n</td>\r\n<td width=\"15%\" align=\"center\">");
// end
// begin [file="/index.jsp";from=(86,34);to=(86,45)]
out.print(total_topic);
// end
// HTML // begin [file="/index.jsp";from=(86,47);to=(87,31)]
out.write("</td>\r\n<td width=\"15%\" align=\"center\">");
// end
// begin [file="/index.jsp";from=(87,34);to=(87,44)]
out.print(total_post);
// end
// HTML // begin [file="/index.jsp";from=(87,46);to=(88,32)]
out.write("</td>\r\n<td width=\"26%\" align=\"left\">by:");
// end
// begin [file="/index.jsp";from=(88,35);to=(88,46)]
out.print(last_forcum);
// end
// HTML // begin [file="/index.jsp";from=(88,48);to=(90,0)]
out.write("</td>\r\n</tr>\r\n");
// end
// begin [file="/index.jsp";from=(90,2);to=(96,0)]
}
conn.close();
}catch(Exception e){
out.println(e);
}
// end
// HTML // begin [file="/index.jsp";from=(96,2);to=(100,0)]
out.write("\r\n</table>\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 + -