• 大小: 6KB
    文件类型: .rar
    金币: 2
    下载: 0 次
    发布日期: 2021-06-08
  • 语言: Java
  • 标签: javaweb  

资源简介

简单javaweb登陆注册界面,适合初学者学习

资源截图

代码片段和文件信息

package com.northwind.actions;

import java.io.IOException;

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

public class UserAction extends HttpServlet {

/**
 * 
 */
private static final long serialVersionUID = 1L;

/**
 * Constructor of the object.
 */
public UserAction() {
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 {

doPost(request response);
}

/**
 * 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
 */
@SuppressWarnings(“unchecked“)
public void doPost(HttpServletRequest request HttpServletResponse response)
throws ServletException IOException {
// 获取前台的内容
String method = request.getParameter(“method“);
String loginid = request.getParameter(“loginid“);
String password = request.getParameter(“password“);
@SuppressWarnings(“unused“)
String msg = ““; // 前台页面显示的内容
if (method == null) {
request.getRequestDispatcher(“/Pages/login.jsp“).forward(request
response);
} else if (“login“.equals(method)) {
if (loginid == ““) { // 如果用户名为空,直接返回错误信息
request.setAttribute(“msg“ “此用户不存在“);
request.getRequestDispatcher(“/Pages/login.jsp“).forward(
request response);
} else if (loginid.equals(“admin“)
&& password.equals(“admin“)) {
request.getRequestDispatcher(“/Pages/success.jsp“).forward(
request response);
} else {
request.setAttribute(“msg“ “用户名或密码错误“);
request.getRequestDispatcher(“/Pages/login.jsp“).forward(
request response);
}
}
}

/**
 * Initialization of the servlet. 

 * 
 * @throws ServletException
 *             if an error occurs
 */
public void init() throws ServletException {
// Put your code here
}

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     目录          0  2012-05-25 10:38  ServerletWeb

     文件        362  2012-05-25 10:38  ServerletWeb\.classpath

     目录          0  2012-05-25 10:38  ServerletWeb\.myeclipse

     文件        309  2012-05-25 10:38  ServerletWeb\.mymetadata

     文件       1418  2012-05-25 11:04  ServerletWeb\.project

     目录          0  2012-05-25 10:38  ServerletWeb\.settings

     文件        406  2012-05-25 10:38  ServerletWeb\.settings\.jsdtscope

     文件         49  2012-05-25 10:38  ServerletWeb\.settings\org.eclipse.wst.jsdt.ui.superType.container

     文件          6  2012-05-25 10:38  ServerletWeb\.settings\org.eclipse.wst.jsdt.ui.superType.name

     目录          0  2012-05-25 10:39  ServerletWeb\src

     目录          0  2012-05-25 10:39  ServerletWeb\src\com

     目录          0  2012-05-25 10:39  ServerletWeb\src\com\northwind

     目录          0  2012-05-25 10:39  ServerletWeb\src\com\northwind\actions

     文件       2969  2012-05-25 10:52  ServerletWeb\src\com\northwind\actions\UserAction.java

     目录          0  2012-05-25 10:52  ServerletWeb\WebRoot

     目录          0  2012-05-25 10:38  ServerletWeb\WebRoot\meta-INF

     文件         39  2012-05-25 10:38  ServerletWeb\WebRoot\meta-INF\MANIFEST.MF

     目录          0  2012-05-25 10:52  ServerletWeb\WebRoot\Pages

     文件        924  2012-05-25 08:29  ServerletWeb\WebRoot\Pages\login.jsp

     文件        228  2012-05-25 08:29  ServerletWeb\WebRoot\Pages\success.jsp

     目录          0  2012-05-25 10:38  ServerletWeb\WebRoot\WEB-INF

     目录          0  2012-05-25 10:39  ServerletWeb\WebRoot\WEB-INF\classes

     目录          0  2012-05-25 10:39  ServerletWeb\WebRoot\WEB-INF\classes\com

     目录          0  2012-05-25 10:39  ServerletWeb\WebRoot\WEB-INF\classes\com\northwind

     目录          0  2012-05-25 10:39  ServerletWeb\WebRoot\WEB-INF\classes\com\northwind\actions

     文件       1965  2012-05-25 10:52  ServerletWeb\WebRoot\WEB-INF\classes\com\northwind\actions\UserAction.class

     目录          0  2012-05-25 10:38  ServerletWeb\WebRoot\WEB-INF\lib

     文件        701  2012-05-25 11:04  ServerletWeb\WebRoot\WEB-INF\web.xml

----------- ---------  ---------- -----  ----

                 9376                    28

............此处省略1个文件信息

评论

共有 条评论