java+jsp+oracle做的bbs

  • G5_168150
    了解作者
  • 2.3MB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-05-26 06:35
    上传日期
用jsp+java+oracle做的BBS。。。。超简单
chen.rar
内容介绍
package com.chenjie.servlets; import com.dao.*; import com.chenji.*; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class LoginServlet extends HttpServlet { /** * Constructor of the object. */ public LoginServlet() { super(); } /** * Destruction of the servlet. <br> */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet. <br> * * 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"); PrintWriter out = response.getWriter(); //response.sendRedirect("file.jsp");//密码用户名都错的跳转到file.jsp } /** * The doPost method of the servlet. <br> * * 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 { response.setContentType("text/html"); PrintWriter out = response.getWriter(); request.setCharacterEncoding("gbk");//获取的时候就转换编码 String u = request.getParameter("user"); String p = request.getParameter("pwd"); DBAccess db = new DBAccess(); Userifor user = db.getUserByUserName(u); //System.out.println("---------------------"+user.getUserName()); if(user!=null&&user.getUserName().equals(u)){ if(user.getPassword().equals(p)){ // RequestDispatcher dis = request.getRequestDispatcher("index.jsp"); // dis.forward(request,response); // System.out.println("before"); response.sendRedirect("succes.jsp"); }else{ response.sendRedirect("register.jsp");//没输入密码时候跳转到regest.jsp //密码错误 } // response.sendRedirect("register.jsp");//没输入密码时候跳转到regest.jsp }else { //用户不存在 response.sendRedirect("register.jsp"); } } /** * Initialization of the servlet. <br> * * @throws ServletException if an error occurs */ public void init() throws ServletException { // Put your code here } }
评论
    相关推荐