基于javaweb+mysql的jsp+servlet招聘平台系统(平台、企业、用户)(java+servlet+mysql+jsp)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的JSP+Servlet招聘平台系统(平台、企业、用户)(java+servlet+mysql+jsp)
http://localhost:8080/xxzp
管理员(admin表):admin 123456
企业(member表):qy111 123456
用户(member表):xs111 123456
else{
int id[]= new int[check.length];
for(int i = 0;i<check.length;i++){
int s = Integer.parseInt(check[i]);
id[i] = s;
}
int flag = mmBean.delMember(id);
if(flag == Constant.SUCCESS){
if(method.equals("DELMEMBER")){//来自所有个人会员页面
request.getRequestDispatcher(sysdir+"/member/person.jsp").forward(request, response);
}
else if(method.equals("DELCO")){//来自所有企业会员页面
request.getRequestDispatcher(sysdir+"/member/co.jsp").forward(request, response);
}
else if(method.equals("DELTODAY")){//来自今日注册会员页面
request.getRequestDispatcher(sysdir+"/member/today.jsp").forward(request, response);
}
else if(method.equals("DELALLCLOSE")){//来自所有冻结会员页面
request.getRequestDispatcher(sysdir+"/member/close.jsp").forward(request, response);
}
else if(method.equals("DELALLUSE")){//来自所有在用会员页面
request.getRequestDispatcher(sysdir+"/member/using.jsp").forward(request, response);
}
}
else{
if(method.equals("DELMEMBER")){//来自所有个人会员页面
request.getRequestDispatcher(sysdir+"/member/person.jsp").forward(request, response);
}
else if(method.equals("DELCO")){//来自所有企业会员页面
request.getRequestDispatcher(sysdir+"/member/co.jsp").forward(request, response);
}
else if(method.equals("DELTODAY")){//来自今日注册会员页面
request.getRequestDispatcher(sysdir+"/member/today.jsp").forward(request, response);
}
else if(method.equals("DELALLCLOSE")){//来自所有冻结会员页面
request.getRequestDispatcher(sysdir+"/member/close.jsp").forward(request, response);
}
else if(method.equals("DELALLUSE")){//来自所有在用会员页面
request.getRequestDispatcher(sysdir+"/member/using.jsp").forward(request, response);
}
}
}
}
else if(method.equals("CLOSE")){
String id=request.getParameter("id").trim();
}
String s = new String(m_binArray,i,(j - i) + 1);
return s;
}
private String getFileName(String s)
{
//String s1 = ""; // = new String();
//String s2 = ""; // = new String();
//boolean flag = false;
//boolean flag1 = false;
//boolean flag2 = false;
int i = 0;
i = s.lastIndexOf('/');
if(i != -1)
{
return s.substring(i + 1,s.length());
}
i = s.lastIndexOf('\\');
if(i != -1)
{
return s.substring(i + 1,s.length());
}
else
{
return s;
}
}
public void setDeniedFilesList(String s) throws ServletException,IOException,SQLException
{
//String s1 = "";
if(s != null)
{
String s2 = "";
for(int i = 0;i < s.length();i++)
{
if(s.charAt(i) == ',')
{
if(!m_deniedFilesList.contains(s2))
{
m_deniedFilesList.addElement(s2);
}
s2 = "";
* 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 {
response.setContentType(Constant.CONTENTTYPE);
request.setCharacterEncoding(Constant.CHARACTERENCODING);
try{
String method=request.getParameter("method").trim();
AdminBean loginbean = new AdminBean();
HttpSession session = request.getSession();
session.setMaxInactiveInterval(1200);
SystemBean systembean = new SystemBean();
String sysdir = systembean.getDir();
if(method.equals("one")){//admin登录
String username = request.getParameter("username");
String password = request.getParameter("password");
if(username == null||username.trim().equals("")){
request.setAttribute("message", "请正确输入用户名!");
request.getRequestDispatcher(sysdir+"/login.jsp").forward(request, response);
}
else if(password == null||password.trim().equals("")){
request.setAttribute("message", "请输入密码!");
request.getRequestDispatcher(sysdir+"/login.jsp").forward(request, response);
}
else{
String md5password = MD5.MD5(password);
String agent = request.getHeader("user-agent");
StringTokenizer st = new StringTokenizer(agent,";");
String useros=st.nextToken();
String loginip = request.getRemoteAddr();
int flag = loginbean.adminLogin(username,md5password, password,useros,loginip);
switch (flag){
case Constant.SUCCESS:
List list = loginbean.getAdminInfo(username);
session.setAttribute("user", username);
session.setAttribute("list", list);
request.getRequestDispatcher(sysdir+"/").forward(request, response);
break;
case Constant.NAME_ERROR:
request.setAttribute("message", "用户名错误!请确认管理权限!");
request.getRequestDispatcher(sysdir+"/login.jsp").forward(request, response);
break;
case Constant.PASSWORD_ERROR:
request.setAttribute("message", "密码错误,请确认管理权限!");
request.getRequestDispatcher(sysdir+"/login.jsp").forward(request, response);
break;
}
}
catch(Exception exception)
{
throw new SmartUploadException("Unable to upload.");
}
}
for(;!flag1 && m_currentIndex < m_totalBytes;m_currentIndex++)
{
if(m_binArray[m_currentIndex] == 13)
{
flag1 = true;
}
else
{
m_boundary = m_boundary + (char)m_binArray[m_currentIndex];
}
}
if(m_currentIndex == 1)
{
return;
}
for(m_currentIndex++;m_currentIndex < m_totalBytes;m_currentIndex = m_currentIndex + 2)
{
long now=new java.util.Date().getTime();
String s1 = getDataHeader();
m_currentIndex = m_currentIndex + 2;
boolean flag3 = s1.indexOf("filename") > 0;
String s3 = getDataFieldValue(s1,"name");
if(flag3)
{
s6 = getDataFieldValue(s1,"filename");
s4 = now+getFileName(s6);
s5 = getFileExt(s4);
s7 = getContentType(s1);
s8 = getContentDisp(s1);
s9 = getTypeMIME(s7);
s10 = getSubTypeMIME(s7);
}
getDataSection();
if(flag3 && s4.length() > 0)
{
if(m_deniedFilesList.contains(s5))
{
throw new SecurityException("The extension of the file is denied to be uploaded (1015).");
}
if(!m_allowedFilesList.isEmpty() && !m_allowedFilesList.contains(s5))
{
throw new SecurityException("The extension of the file is not allowed to be uploaded (1010).");
}
if(m_maxFileSize > 0L && (long)((m_endData - m_startData) + 1) > m_maxFileSize)
request.getRequestDispatcher("admin/jl/index.jsp").forward(request, response);
}
else {
request.setAttribute("message", "操作失败!");
request.getRequestDispatcher("admin/jl/index.jsp").forward(request, response);
}
}
else if(method.equals("sqGW")){ //申请岗位
String zid = request.getParameter("zid");
String type=(String)session.getAttribute("type");
String member=(String)session.getAttribute("member");
String qymember=cBean.getString("select `member` from zp where id='"+zid+"'");
if(type==null||type.equals("企业")){
request.setAttribute("message", "未登录或用户身份错误!");
request.getRequestDispatcher("index.jsp").forward(request, response);
}
else{
int flag = cBean.comUp("insert into sc(zid,`member`,qymember) values('"+zid+"','"+member+"','"+qymember+"')");
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("zp.jsp").forward(request, response);
}
else {
request.setAttribute("message", "操作失败!");
request.getRequestDispatcher("zp.jsp").forward(request, response);
}
}
}
else if(method.equals("delSC")){ //删除申请
String id = request.getParameter("id");
int flag = cBean.comUp("delete from sc where id='"+id+"'");
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("member/jl/ysq.jsp").forward(request, response);
}
else {
request.setAttribute("message", "操作失败!");
request.getRequestDispatcher("member/jl/ysq.jsp").forward(request, response);
}
}
else if(method.equals("delSC2")){ //del
String id = request.getParameter("id");
}
protected String getPhysicalPath(String s,int i) throws IOException
{
String s1 = ""; //new String();
String s2 = ""; //new String();
String s3 = ""; //new String();
boolean flag = false;
s3 = System.getProperty("file.separator");
if(s == null)
{
throw new IllegalArgumentException("There is no specified destination file (1140).");
}
if(s.equals(""))
{
throw new IllegalArgumentException("There is no specified destination file (1140).");
}
if(s.lastIndexOf("\\") >= 0)
{
s1 = s.substring(0,s.lastIndexOf("\\"));
s2 = s.substring(s.lastIndexOf("\\") + 1);
}
if(s.lastIndexOf("/") >= 0)
{
s1 = s.substring(0,s.lastIndexOf("/"));
s2 = s.substring(s.lastIndexOf("/") + 1);
}
s1 = s1.length() != 0 ? s1 : "/";
java.io.File file = new java.io.File(s1);
if(file.exists())
{
flag = true;
}
if(i == 0)
{
if(isVirtual(s1))
{
s1 = m_application.getRealPath(s1);
if(s1.endsWith(s3))
{
s1 = s1 + s2;
}
else
{
s1 = s1 + s3 + s2;
}
return s1;
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
}
/**
* The doPost method of the servlet. <br>
*
* 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(Constant.CHARACTERENCODING);
response.setContentType(Constant.CONTENTTYPE);
HttpSession session = request.getSession();
String date=new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime());
String date2=new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
try{
String method = null;
ComBean cb=new ComBean();
SmartUpload mySmartUpload = new SmartUpload();//init
int count = 0;
try{
mySmartUpload.initialize(config,request,response);
mySmartUpload.upload();
method = mySmartUpload.getRequest().getParameter("method").trim();
if(method.equals("JL")){//增加
/**
* String xm = ""; String url="";String xb=""; String sfz="";String xl="";String yx="";
String zy="";String cj="";String hj="";String sx=""; String lx=""; String dz="";
*/
String xm=mySmartUpload.getRequest().getParameter("xm");
String xb=mySmartUpload.getRequest().getParameter("xb");
String sfz=mySmartUpload.getRequest().getParameter("sfz");
String xl=mySmartUpload.getRequest().getParameter("xl");
String yx=mySmartUpload.getRequest().getParameter("yx");
String zy=mySmartUpload.getRequest().getParameter("zy");
String cj=mySmartUpload.getRequest().getParameter("cj");
String hj=mySmartUpload.getRequest().getParameter("hj");
String sx=mySmartUpload.getRequest().getParameter("sx");
/**
* Constructor of the object.
*/
public UpServlet() {
super();
}
final public void init(ServletConfig config) throws ServletException
{
this.config = config;
}
final public ServletConfig getServletConfig()
{
return config;
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* 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);
}
* @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 {
response.setContentType(Constant.CONTENTTYPE);
request.setCharacterEncoding(Constant.CHARACTERENCODING);
HttpSession session = request.getSession();
MemberBean memberBean = new MemberBean();
String method = Filter.escapeHTMLTags(request.getParameter("method").trim());
/*********************************************
* 会员注册通用(检查用户名 修改密码 reg2.jsp页面跳转)
*********************************************/
if(method.equals("reg2")){//会员注册 reg2.jsp
String username = Filter.escapeHTMLTags(request.getParameter("username").trim());
String password = Filter.escapeHTMLTags(request.getParameter("password").trim());
String reg_type = Filter.escapeHTMLTags(request.getParameter("reg_type").trim());
request.setAttribute("username", username);
request.setAttribute("password", password);
request.setAttribute("reg_type", reg_type);
if(username.trim().equals("admin")){
request.setAttribute("username", username);
request.setAttribute("message", "非法的用户名,请重新选择!");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
else{
int flag = memberBean.checkRegName(username);
if(flag == Constant.SUCCESS){
if(reg_type.equals("person")){//如果是个人会员
request.getRequestDispatcher("personreg.jsp").forward(request, response);
}
else if(reg_type.equals("co")){//如果是企业会员
request.getRequestDispatcher("coreg.jsp").forward(request, response);
}
else{
request.getRequestDispatcher("index.jsp").forward(request, response);
}
}
else if(flag == Constant.SAME_NAME){
request.setAttribute("username", username);
request.setAttribute("message", "对不起,该用户名已存在,请重新选择!");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
else{
int flag = cBean.comUp("insert into ly(zid,qymember,nr,grmember,sj) values('"+zid+"','"+qymember+"','"+nr+"','"+member+"','"+date2+"')");
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("index.jsp").forward(request, response);
}
else {
request.setAttribute("message", "操作失败!");
request.getRequestDispatcher("index.jsp").forward(request, response);
}
}
}
else if(method.equals("delly")){ //del
String id = request.getParameter("id");
int flag = cBean.comUp("delete from ly where id='"+id+"'");
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("member/xx/index.jsp").forward(request, response);
}
else {
request.setAttribute("message", "操作失败!");
request.getRequestDispatcher("member/xx/index.jsp").forward(request, response);
}
}
else if(method.equals("delly2")){ //del
String id = request.getParameter("id");
int flag = cBean.comUp("delete from ly where id='"+id+"'");
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("member/xx/index2.jsp").forward(request, response);
}
else {
request.setAttribute("message", "操作失败!");
request.getRequestDispatcher("member/xx/index2.jsp").forward(request, response);
}
}
else if(method.equals("hfly")){ //回复留言
String lyid = request.getParameter("lyid");
String hf = request.getParameter("hf");
int flag = cBean.comUp("update ly set hf='"+hf+"',hfsj='"+date2+"' where id='"+lyid+"'");
if(flag == Constant.SUCCESS){
response.setContentType(Constant.CONTENTTYPE);
HttpSession session = request.getSession();
String date=new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime());
String date2=new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
try{
String method = null;
ComBean cb=new ComBean();
SmartUpload mySmartUpload = new SmartUpload();//init
int count = 0;
try{
mySmartUpload.initialize(config,request,response);
mySmartUpload.upload();
method = mySmartUpload.getRequest().getParameter("method").trim();
if(method.equals("JL")){//增加
/**
* String xm = ""; String url="";String xb=""; String sfz="";String xl="";String yx="";
String zy="";String cj="";String hj="";String sx=""; String lx=""; String dz="";
*/
String xm=mySmartUpload.getRequest().getParameter("xm");
String xb=mySmartUpload.getRequest().getParameter("xb");
String sfz=mySmartUpload.getRequest().getParameter("sfz");
String xl=mySmartUpload.getRequest().getParameter("xl");
String yx=mySmartUpload.getRequest().getParameter("yx");
String zy=mySmartUpload.getRequest().getParameter("zy");
String cj=mySmartUpload.getRequest().getParameter("cj");
String hj=mySmartUpload.getRequest().getParameter("hj");
String sx=mySmartUpload.getRequest().getParameter("sx");
String lx=mySmartUpload.getRequest().getParameter("lx");
String dz=mySmartUpload.getRequest().getParameter("dz");
SmartFile file = mySmartUpload.getFiles().getFile(0);
String fileExt=file.getFileExt();
String path="/pic";
count = mySmartUpload.save(path);
String member=(String)session.getAttribute("member");
String str=cb.getString("select id from jl where member='"+member+"'");
String sql="";
if(str==null){
sql="insert into jl( xm ,url, xb, sfz, xl, yx, zy, cj, hj, sx, lx, dz,member,flag)" +
"values('"+xm+"','"+path+"/"+file.getFileName()+"','"+xb+"' ,'"+sfz+"','"+xl+"','"+yx+"','"+zy+"','"+cj+"','"+hj+"'" +
",'"+sx+"','"+lx+"','"+dz+"','"+member+"','未审核')";
}
else{
sql="update jl set xm='"+xm+"',url='"+path+"/"+file.getFileName()+"',xb='"+xb+"' ,sfz='"+sfz+"',xl='"+xl+"'," +
"yx='"+yx+"',zy='"+zy+"',cj='"+cj+"',hj='"+hj+"'" +
",sx='"+sx+"',lx='"+lx+"',dz='"+dz+"' where member='"+member+"'";
}
int flag=cb.comUp(sql);
//int flag=pb.addBOOK(id,booktype, name, author, path+"/"+file.getFileName(), isbn, price, num, intro, jyjg,addtime);
if(flag==Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("member/jl/index.jsp").forward(request, response);
}
}
}
else if(method.equals("delly")){ //del
String id = request.getParameter("id");
int flag = cBean.comUp("delete from ly where id='"+id+"'");
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("member/xx/index.jsp").forward(request, response);
}
else {
request.setAttribute("message", "操作失败!");
request.getRequestDispatcher("member/xx/index.jsp").forward(request, response);
}
}
else if(method.equals("delly2")){ //del
String id = request.getParameter("id");
int flag = cBean.comUp("delete from ly where id='"+id+"'");
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("member/xx/index2.jsp").forward(request, response);
}
else {
request.setAttribute("message", "操作失败!");
request.getRequestDispatcher("member/xx/index2.jsp").forward(request, response);
}
}
else if(method.equals("hfly")){ //回复留言
String lyid = request.getParameter("lyid");
String hf = request.getParameter("hf");
int flag = cBean.comUp("update ly set hf='"+hf+"',hfsj='"+date2+"' where id='"+lyid+"'");
if(flag == Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("member/xx/index2.jsp").forward(request, response);
}
else {
request.setAttribute("message", "操作失败!");
request.getRequestDispatcher("member/xx/index2.jsp").forward(request, response);
}
}
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
}
}
else if(method.equals("checksame")){//检查注册名是否可用
String username = Filter.escapeHTMLTags(request.getParameter("username").trim());
if(username.trim().equals("admin")){
request.setAttribute("username", username);
request.setAttribute("message", "非法的用户名,请重新选择!");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
else{
int flag = memberBean.checkRegName(username);
if(flag == Constant.SUCCESS){
request.setAttribute("username", username);
request.setAttribute("message", "恭喜您,这个名字可以使用!");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
else if(flag == Constant.SAME_NAME){
request.setAttribute("username", username);
request.setAttribute("message", "对不起,该用户名已存在,请重新选择!");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("reg2.jsp").forward(request, response);
}
}
}
else if(method.equals("Editpwd")){//会员修改登陆密码
String member=(String)session.getAttribute("member");
String type=(String)session.getAttribute("type");
if(member==null||type==null){
response.sendRedirect("error.jsp");
}
else{
String oldpwd = MD5.MD5(request.getParameter("oldpwd").trim());
String newpwd = MD5.MD5(request.getParameter("newpwd").trim());
int flag = memberBean.editPassword(member, oldpwd, newpwd);
switch (flag){
case Constant.SUCCESS:
request.setAttribute("message", "密码修改成功!");
request.getRequestDispatcher("member/info/editpwd.jsp").forward(request, response);
break;
case Constant.PASSWORD_ERROR:
request.setAttribute("message", "原始密码错误,请确认权限!");
request.getRequestDispatcher("member/info/editpwd.jsp").forward(request, response);
SmartFile file = mySmartUpload.getFiles().getFile(0);
String fileExt=file.getFileExt();
String path="/pic";
count = mySmartUpload.save(path);
String member=(String)session.getAttribute("member");
int flag=cb.comUp("insert into qy(mc,url,content,member) values('"+mc+"','"+path+"/"+file.getFileName()+"','"+content+"','"+member+"' )");
//int flag=pb.addBOOK(id,booktype, name, author, path+"/"+file.getFileName(), isbn, price, num, intro, jyjg,addtime);
if(flag==Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("member/qy/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("member/qy/index.jsp").forward(request, response);
}
}
else if(method.equals("upqyjs")){//修改
String member=(String)session.getAttribute("member");
String mc=mySmartUpload.getRequest().getParameter("mc");
String content=mySmartUpload.getRequest().getParameter("infoContent");
SmartFile file = mySmartUpload.getFiles().getFile(0);
String fileExt=file.getFileExt();
String path="/pic";
count = mySmartUpload.save(path);
int flag=cb.comUp("update qy set mc='"+mc+"' ,url='"+path+"/"+file.getFileName()+"'," +
"content='"+content+"' where member='"+member+"'");
//int flag=pb.upBOOK(id, booktype, name, author, path+"/"+file.getFileName(), isbn, price, num, intro, jyjg,addtime);
if(flag==Constant.SUCCESS){
request.setAttribute("message", "操作成功!");
request.getRequestDispatcher("member/qy/index.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher("member/qy/index.jsp").forward(request, response);
}
}
else{
request.getRequestDispatcher("error.jsp").forward(request, response);
}
}catch(Exception ex){
ex.printStackTrace();
//request.getRequestDispatcher("error.jsp").forward(request, response);
}
}catch(Exception e){
e.printStackTrace();
request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
else if(method.equals("dellog")){//delete login note
String username2 = (String)session.getAttribute("user");
if(username2 == null){
request.getRequestDispatcher("error.jsp").forward(request, response);
}
else{
String check[] = request.getParameterValues("checkit");
if(check == null){
request.setAttribute("message", "请选择要删除的记录!");
request.getRequestDispatcher(sysdir+"/system/log.jsp").forward(request, response);
}
else{
int id[]= new int[check.length];
for(int i = 0;i<check.length;i++){
int s = Integer.parseInt(check[i]);
id[i] = s;
}
int flag = loginbean.delLog(id);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "删除记录成功!");
request.getRequestDispatcher(sysdir+"/system/log.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/system/log.jsp").forward(request, response);
}
}
}
}
else{//无参数传入转到错误页面
request.getRequestDispatcher("error.jsp").forward(request, response);
}
}catch(Exception e){
e.printStackTrace();
request.getRequestDispatcher("error.jsp").forward(request, response);
}
}
/**
* Initialization of the servlet. <br>
public class AdminAction extends HttpServlet {
/**
* Constructor of the object.
*/
public AdminAction() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* 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. <br>
*
* 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
if(username2 == null){
request.getRequestDispatcher("error.jsp").forward(request, response);
}
else{
String username = request.getParameter("username").trim();
String password = MD5.MD5(request.getParameter("password").trim());
int flag = loginbean.addManager(username, password, "2", "1");
if(flag == Constant.SUCCESS){
request.setAttribute("message", "增加管理员成功!");
request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response);
}
else if(flag == Constant.SAME_NAME){
request.setAttribute("username", username);
request.setAttribute("message", "该用户名已经存在!");
request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response);
}
}
}
else if(method.equals("delm")){//delete manager
String username2 = (String)session.getAttribute("user");
if(username2 == null){
request.getRequestDispatcher("error.jsp").forward(request, response);
}
else{
int id = Integer.parseInt(request.getParameter("id").trim());
if(id == 1){
request.setAttribute("message", "不能删除原始帐号!");
request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response);
}
else{
int flag = loginbean.delManager(id);
if(flag == Constant.SUCCESS){
request.setAttribute("message", "删除成功!");
request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response);
}
else{
request.setAttribute("message", "系统维护中,请稍后再试!");
request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response);
}