JSP之登录,注册页面(三)

摘要:本系列会制作一个简单的需要JSP,servlet,oracle一起完成的登录,注册页面

 

6,注册界面  regist.jsp

 1 <%@ page language="java" import="java.util.*" pageEncoding="GBK" contentType="text/html; charset=GBK"%>
 2 <%
 3 String path = request.getContextPath();
 4 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
 5 %>
 6 
 7 
 8 
 9   
10     
11     
12     My JSP 'regist.jsp' starting page
13     
14     
15     
16         
17     
18     
19     
22 
23   
24   
25   
26     
27 登录名:
28 密  码:
29 30
31 32 33

 

7,用来服务注册的servlet  regist.java

 1 package servlet;
 2 
 3 import java.io.IOException;
 4 
 5 import javax.servlet.ServletException;
 6 import javax.servlet.ServletRequest;
 7 import javax.servlet.ServletResponse;
 8 import javax.servlet.annotation.WebServlet;
 9 import javax.servlet.http.HttpServlet;
10 
11 import dao.userdata;
12 @WebServlet(urlPatterns={"/regist"})
13 public class regist extends HttpServlet{
14     userdata dao;
15 
16     @Override
17     public void service(ServletRequest req, ServletResponse res)
18             throws ServletException, IOException {
19         req.setCharacterEncoding("GBK");
20         String name=req.getParameter("name");
21         String pass=req.getParameter("password");
22         dao=userdata.getdao();
23         dao.regist(name, pass);
24         req.getRequestDispatcher("login.jsp").forward(req, res);
25     }
26     
27     
28     
29 }

 

转载于:https://www.cnblogs.com/ztyy04126/p/4960561.html

你可能感兴趣的:(JSP之登录,注册页面(三))