⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 deleteexamsuspend.java

📁 servlet做控制层示例
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   DeleteExamSuspend.java

package com.saintbo.servlet.student;

import com.saintbo.entity.student.TblExamSuspend;
import com.saintbo.javabean.sys.UserInfo;
import com.saintbo.servlet.MyExtendedServlet;
import com.saintbo.session.student.StudentSessionLocal;
import com.saintbo.session.student.StudentSessionLocalHome;
import com.saintbo.util.upload.RequestHashtable;
import com.saintbo.util.upload.UploadRequest;
import java.io.IOException;
import javax.naming.InitialContext;
import javax.servlet.*;
import javax.servlet.http.HttpSession;

public class DeleteExamSuspend extends MyExtendedServlet
{

    public DeleteExamSuspend()
    {
    }

    public void handle()
        throws IOException, ServletException
    {
        UserInfo userInfo = (UserInfo)session.getAttribute("USERINFO");
        if(userInfo == null || !userInfo.getUserType().equals(new Integer(1)) || !userInfo.getUserType().equals(new Integer(3)))
        {
            int timeOut = session.getMaxInactiveInterval() / 60;
            String errorMessage = "您还没有登录;或者您已经超过" + timeOut + "分钟没有活动,导致会话丢失;或者您没有相应的操作权限。请返回<a href=\"/index.jsp\">首页</a>登录.";
            session.setAttribute("ERRORMESSAGE", errorMessage);
            getServletContext().getRequestDispatcher("/error/error.jsp").forward(req, res);
            return;
        }
        reqInfo = UploadRequest.upload(req);
        Long rowsID = new Long((String)reqInfo.get("RowsID"));
        String studentID = (String)reqInfo.get("StudentID");
        String userID = userInfo.getUserID();
        TblExamSuspend examSuspend = null;
        String errorMessage = "";
        boolean result = false;
        if(rowsID != null && studentID != null && !studentID.trim().equals(""))
            try
            {
                InitialContext jndiContext = new InitialContext();
                StudentSessionLocalHome home = (StudentSessionLocalHome)jndiContext.lookup("StudentSessionLocal");
                StudentSessionLocal local = home.create();
                examSuspend = local.getStudExamSuspendByID(rowsID);
                if(examSuspend != null && examSuspend.getRowsID() != null)
                {
                    if(userInfo.getUserType().equals(new Integer(3)))
                    {
                        examSuspend.remove();
                        result = true;
                    } else
                    if(examSuspend.getApplyStatus() == new Integer(0) && userInfo.getUserType().equals(new Integer(1)))
                    {
                        if(!userID.equals(examSuspend.getStudentID()))
                        {
                            errorMessage = "不能删除别人的缓考信息.";
                        } else
                        {
                            examSuspend.remove();
                            result = true;
                        }
                    } else
                    {
                        errorMessage = "该缓考信息已经回复,不能再修改.";
                    }
                } else
                {
                    errorMessage = "在数据库中找不到该条学生的缓考信息.";
                }
                local.remove();
                jndiContext.close();
            }
            catch(Exception e)
            {
                errorMessage = "当删除学生缓考信息时出现错误.";
                result = false;
                e.printStackTrace();
            }
        else
            errorMessage = "传进来的学生学号不能为空.";
        if(result)
        {
            getServletContext().getRequestDispatcher("/student/studexamsuspendlist.jsp").forward(req, res);
        } else
        {
            session.setAttribute("ERRORMESSAGE", errorMessage);
            getServletContext().getRequestDispatcher("/error/error.jsp").forward(req, res);
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -