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

📄 addstudentregister.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:   AddStudentRegister.java

package com.saintbo.servlet.student;

import com.saintbo.entity.student.TblStudentRegister;
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 AddStudentRegister extends MyExtendedServlet
{

    public AddStudentRegister()
    {
    }

    public void handle()
        throws IOException, ServletException
    {
        UserInfo userInfo = (UserInfo)session.getAttribute("USERINFO");
        int userAuthority = super.checkAuthority(userInfo, 1, 0);
        if(userAuthority != 1)
            return;
        reqInfo = UploadRequest.upload(req);
        String studentID = "";
        String isRegisterID = "0";
        String isPaid = "0";
        String sltCourseStatus = "0";
        if(userInfo.getUserType().equals(new Integer(1)))
            studentID = userInfo.getUserID();
        else
        if(userInfo.getUserType().equals(new Integer(3)))
        {
            studentID = (String)reqInfo.get("StudentID");
            isRegisterID = (String)reqInfo.get("IsRegisterID");
            isPaid = (String)reqInfo.get("IsPaid");
            sltCourseStatus = (String)reqInfo.get("SltCourseStatus");
        }
        String years = (String)reqInfo.get("Years");
        String termID = (String)reqInfo.get("TermID");
        String specialtyID = (String)reqInfo.get("SpecialtyID");
        String regTypeID = (String)reqInfo.get("RegTypeID");
        TblStudentRegister studentRegister = null;
        String errorMessage = "";
        boolean result = false;
        if(studentID != null && !studentID.trim().equals(""))
            try
            {
                InitialContext jndiContext = new InitialContext();
                StudentSessionLocalHome home = (StudentSessionLocalHome)jndiContext.lookup("StudentSessionLocal");
                StudentSessionLocal local = home.create();
                studentRegister = local.addStudentRegister(studentID, years, termID, specialtyID, regTypeID, isRegisterID, isPaid, sltCourseStatus);
                local.remove();
                jndiContext.close();
                result = true;
            }
            catch(Exception e)
            {
                errorMessage = "当学生申请辅修/注册时出现错误.";
                result = false;
                e.printStackTrace();
            }
        else
            errorMessage = "传进来的学生学号不能为空.";
        if(result)
        {
            getServletContext().getRequestDispatcher("/student/studregister.jsp?RowsID=" + studentRegister.getRowsID()).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 + -