Chinaunix首页 | 论坛 | 博客
  • 博客访问: 717264
  • 博文数量: 158
  • 博客积分: 6010
  • 博客等级: 准将
  • 技术积分: 1643
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-11 14:37
个人简介

人法地,地法天,天法道,道法自然

文章分类

全部博文(158)

文章存档

2022年(1)

2020年(3)

2016年(1)

2014年(7)

2013年(4)

2010年(5)

2009年(86)

2008年(25)

2007年(26)

我的朋友

分类: Java

2007-10-12 19:43:49

2. Servlet代码:(workmain.java                                                 

 

package com.maye.suitem.login;

 

import java.io.IOException;

import java.io.PrintWriter;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

 

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.maye.suitem.Conn.Conn;

import com.maye.suitem.Security.MessageMD5;

import com.maye.suitem.javabeans.Atea;

import com.maye.suitem.Config.System_config;

public class workmain extends HttpServlet {

 

             /**

              * 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");

                           response.setCharacterEncoding("UTF-8");

                           request.setCharacterEncoding("UTF-8");

                           PrintWriter out = response.getWriter();

                            String action = request.getParameter("action");

                   if ("zhuxiao".equalsIgnoreCase(action)||"exit".equalsIgnoreCase(action)) {

                   HttpSession session=request.getSession(true);

                     session.invalidate();

                   

                     RequestDispatcher rd = getServletContext().getRequestDispatcher("/index.jsp");

                     rd.forward(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

              */

             public void doPost(HttpServletRequest request, HttpServletResponse response)

                                         throws ServletException, IOException {

                           request.setCharacterEncoding("UTF-8");

                           response.setContentType("text/xml; charset=UTF-8");

                           response.setCharacterEncoding("UTF-8");

        response.setHeader("Cache-Control", "no-cache");

        PrintWriter out = response.getWriter();

                           HttpSession  session=request.getSession();

                           String action=request.getParameter("action");

                           String leix=request.getParameter("leix");

                          

                           if("login".equals(action)&&"teacher".equals(leix)){

                                         doTeacher(request,response);

                           }

        if("login".equals(action)&&"checker".equals(leix)){

                     doChecker(request,response);

                           }

        if("login".equals(action)&&"manager".equals(leix)){

                     doManager(request,response);

        }

        out.close();

}

 

 

注:以上只是部分代码(略)

 

 

阅读(991) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2008-09-10 14:15:41

http://www.sap99.com/ ,SAP免费资料下载 SAP99资料多多 http://www.sap99.com 有很多的学习资料,推荐一下,