资源简介
BBS论坛留言板,改进版。BBS论坛留言板,改进版。BBS论坛留言板,改进版。
代码片段和文件信息
package action;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import dbUtils.DBUtils;
import entity.Message;
public class LoginAction extends HttpServlet {
/**
* Constructor of the object.
*/
public LoginAction() {
super();
}
/**
* Destruction of the servlet.
*/
public void destroy() {
super.destroy(); // Just puts “destroy“ string in log
// Put your code here
}
/**
* The doGet method of the servlet.
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request HttpServletResponse response)
throws ServletException IOException {
response.setContentType(“text/html;charset=UTF-8“);
request.setCharacterEncoding(“UTF-8“);
String username = request.getParameter(“username“);
String password = request.getParameter(“password“);
//System.out.println(username+“:“+password);
HttpSession session = request.getSession();
//request.setAttribute(“username“ username);
session.setAttribute(“username“ username);
System.out.println(session.getAttribute(“username“));
DBUtils.getConn();
Integer temp = DBUtils.getAUser(username password);
if(temp!=null){
List list = DBUtils.getAllMessage();
session.setAttribute(“messageList“ list);
//System.out.println(list.listIterator());
/*Message m = list.get(0);
System.out.println(m.getContent()+“*************“);*/
response.sendRedirect(“home.jsp“);
}
response.setContentType(“text/html“);
PrintWriter out = response.getWriter();
out.println(““);
out.println(““);
out.println(“ tle>A Servlet tle>“);
out.println(“ “);
out.println(“请输入正确的用户名和密码! “);
out.println(“ “);
out.println(““);
out.flush();
out.close();
}
/**
* The doPost method of the servlet.
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request HttpServletResponse response)
throws ServletException IOException {
doGet(request
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-06-19 15:12 BBS\
目录 0 2017-06-19 15:12 BBS\BBs\
文件 2940 2017-06-15 15:36 BBS\bbs.sql
文件 1186 2017-06-11 09:36 BBS\BBs\.classpath
文件 1328 2017-06-11 09:56 BBS\BBs\.project
目录 0 2017-06-19 15:12 BBS\BBs\.settings\
文件 522 2017-06-11 09:24 BBS\BBs\.settings\.jsdtscope
文件 364 2017-06-11 09:24 BBS\BBs\.settings\org.eclipse.jdt.core.prefs
文件 468 2017-06-11 09:24 BBS\BBs\.settings\org.eclipse.wst.common.component
文件 414 2017-06-11 09:24 BBS\BBs\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 49 2017-06-11 09:24 BBS\BBs\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2017-06-11 09:24 BBS\BBs\.settings\org.eclipse.wst.jsdt.ui.superType.name
目录 0 2017-06-19 15:12 BBS\BBs\src\
目录 0 2017-06-19 15:12 BBS\BBs\src\action\
文件 3708 2017-06-12 10:54 BBS\BBs\src\action\LoginAction.java
文件 4225 2017-06-15 15:33 BBS\BBs\src\action\MessageAction.java
文件 3176 2017-06-12 11:01 BBS\BBs\src\action\RegisterAction.java
目录 0 2017-06-19 15:12 BBS\BBs\src\dbUtils\
文件 5143 2017-06-15 15:36 BBS\BBs\src\dbUtils\DBUtils.java
目录 0 2017-06-19 15:12 BBS\BBs\src\entity\
文件 866 2017-06-15 15:04 BBS\BBs\src\entity\Message.java
文件 492 2017-06-11 09:45 BBS\BBs\src\entity\User.java
目录 0 2017-06-19 15:12 BBS\BBs\WebRoot\
文件 1175 2017-06-15 15:08 BBS\BBs\WebRoot\addMessage.jsp
文件 1767 2017-06-15 15:35 BBS\BBs\WebRoot\home.jsp
文件 834 2017-06-11 09:24 BBS\BBs\WebRoot\index.jsp
文件 2041 2017-06-12 10:40 BBS\BBs\WebRoot\login.jsp
目录 0 2017-06-19 15:12 BBS\BBs\WebRoot\me
文件 39 2017-06-11 09:24 BBS\BBs\WebRoot\me
文件 1976 2017-06-12 10:49 BBS\BBs\WebRoot\register.jsp
文件 876 2017-06-11 12:07 BBS\BBs\WebRoot\regSuccess.jsp
............此处省略15个文件信息
评论
共有 条评论