用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - java代码库

实现预约功能

2016-05-15 作者: 云代码会员举报

[java]代码库

package com.hospital.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Map;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.hospital.constant.MyConstant;
import com.hospital.model.User;
import com.hospital.util.DaoUtil;

public class Login extends HttpServlet {


    /**
     * Destruction of the servlet. <br>
     */
    public void destroy() {
        super.destroy(); // Just puts "destroy" string in log
        // Put your code here
    }

    /**
     * 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;charset=utf-8");
        request.setCharacterEncoding("utf-8");
        PrintWriter out = response.getWriter();
        
        String username=request.getParameter("username");
        String password=request.getParameter("password");
        
        if (username.equals(MyConstant.userName)){
            if (password.equals(MyConstant.password)){
                RequestDispatcher requestDispatcher = request.getRequestDispatcher("../mainFram.jsp");
                requestDispatcher.forward(request, response);
                
            }
            else {
                PrintWriter pw = response.getWriter();
                pw.println("<script>alert('您输入的密码有误!')</script>");
                pw.println("<script>window.location.href='../Login.jsp';</script>");
                pw.flush();
                pw.close();
            }
        }
        else {
            PrintWriter pw = response.getWriter();
            pw.println("<script>alert('您输入的帐号有误!')</script>");
            pw.println("<script>window.location.href='../Login.jsp';</script>");
            pw.flush();
            pw.close();
        }
        
            
        
        
        

    }

    /**
     * Initialization of the servlet. <br>
     *
     * @throws ServletException if an error occurs
     */
    public void init() throws ServletException {
        // Put your code here
    }

}


网友评论    (发表评论)

共4 条评论 1/1页

发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...