基于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/servlet/MainPageServlet
管理员:
admin 123456
企业:
ep1 123456
ep2 123456
ep3 123456
学生:
stu1 123456
stu2 123456
stu3 123456
注意:每个公司只能发布一个职位(职位表有公司名唯一约束:tb_eppostjob)
//如果搜索框搜索
try {
//创建企业用户名的ArrayList
ArrayList<String> usernames = new ArrayList<String>();
//创建EPPostJobDao数据库操作对象
EPPostJobDao eppjd = new EPPostJobDao();
usernames = eppjd.queryEPPostJob(address, jobkind, trade);
//将usernames放入session中
HttpSession session = request.getSession();
session.setAttribute("EPusernames", usernames);
//创建EPData和EPPostJob对象,并搜索对应公司用户名的EPData和EPPostJob
ArrayList<EPData> epds = new ArrayList<EPData>();
ArrayList<EPPostJob> eppjs = new ArrayList<EPPostJob>();
if(usernames.size() > 0){
for (String username : usernames) {
EPData epd = new EPData();
EPPostJob eppj = new EPPostJob();
//创建EPDataDao数据库操作对象进行查找
EPDataDao epdd = new EPDataDao();
epd = epdd.getEPData(username);
epds.add(epd);
//使用EPPostJobDao数据库操作对象进行查找
eppj = eppjd.getEPPostJob(username);
eppjs.add(eppj);
}
//创建StuSelectResult对象,将要显示的信息重新组装
ArrayList<StuSelectResult> arrSsr = new ArrayList<StuSelectResult>();
StuSelectResult ssr = null;
for (int i = 0; i < epds.size(); i++) {
ssr = new StuSelectResult();
ssr.setEPusername(eppjs.get(i).getEPusername());
ssr.setJobname(eppjs.get(i).getJobname());
ssr.setEPname(epds.get(i).getEPname());
ssr.setJobaddr(epds.get(i).getEPaddr());
ssr.setSalary(eppjs.get(i).getJobsalary());
arrSsr.add(ssr);
}
//将arrSsr存入request中
request.setAttribute("arrSsr", arrSsr);
}else{
request.setAttribute("error", "暂无结果");
}
} catch (SQLException e) {
e.printStackTrace();
}
//通过StuHomeServlet转向stuHome.jsp页面
request.getRequestDispatcher("StuHomeServlet").forward(request, response);
}
* 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 {
//创建公司用户名list
ArrayList<String> arrEpUsername = new ArrayList<String>();
//创建StuStoreDao数据库操作对象
StuStoreDao ssd = new StuStoreDao();
//从session中获取毕业生用户名
HttpSession session = request.getSession();
String stuUsername = (String) session.getAttribute("stuUser");
try {
//从数据库中查询此毕业生用户所收藏的公司账户名
arrEpUsername = ssd.queryStuStore(stuUsername);
session.setAttribute("storeEPnames", arrEpUsername);
//如果arrEpUsername为空
if(arrEpUsername.size() == 0){
//传递信息到前端页面
request.setAttribute("info", "您暂时无收藏的公司");
}else{
//创建查询结果的List
ArrayList<StuSelectResult> arrSsr = new ArrayList<StuSelectResult>();
//创建StuSelectResult对象
StuSelectResult ssr = null;
//创建EPData对象
EPData epd = new EPData();
//创建EPPostJob对象
EPPostJob eppj = new EPPostJob();
//创建EPDataDao和EPPostJobDao对象
EPDataDao epdd = new EPDataDao();
EPPostJobDao eppjd = new EPPostJobDao();
//遍历arrEpUsername
for (String epUsername : arrEpUsername) {
ssr = new StuSelectResult();
ssr.setEPusername(epUsername);
//根据epUsername查询出EPData
epd = epdd.getEPData(epUsername);
ssr.setEPname(epd.getEPname());
int age = now - bir;
request.setAttribute("age", age);
//对校内职务字符串eduduty进行处理
String eduDuty = e.getEduduty();
String[] eduDutys = eduDuty.split("\r\n");
StringBuilder sbDuty = new StringBuilder();
for(int i = 0;i < eduDutys.length; i++){
sbDuty.append(eduDutys[i].toCharArray());
sbDuty.append("<br>".toCharArray());
}
request.setAttribute("eduduty", sbDuty);
//对在校奖励字符串eduaward进行处理
String eduAward = e.getEduaward();
String[] eduAwards = eduAward.split("\r\n");
StringBuilder sbAward = new StringBuilder();
for(int i = 0;i < eduAwards.length; i++){
sbAward.append(eduAwards[i].toCharArray());
sbAward.append("<br>".toCharArray());
}
request.setAttribute("eduaward", sbAward);
//对社会实践字符串eduprictise进行处理
String eduPrictise = e.getEduprictise();
String[] eduPrictises = eduPrictise.split("\r\n");
StringBuilder sbPrictise = new StringBuilder();
for(int i = 0;i < eduPrictises.length;i++){
sbPrictise.append(eduPrictises[i]);
sbPrictise.append("<br>");
}
request.setAttribute("eduprictise", sbPrictise);
//对自我评价字符串evaluation进行处理
String evaluation = ji.getEvaluation();
char[] evaluations = evaluation.toCharArray();
StringBuilder sbEvaluation = new StringBuilder();
for(int i = 0;i < evaluations.length; i++){
sbEvaluation.append(evaluations[i]);
if((i+1)%35 == 0){
sbEvaluation.append("<br>".toCharArray());
}
}
request.setAttribute("evaluation", sbEvaluation);
//转向stuResumeDetail.jsp页面
request.getRequestDispatcher("../stuResumeDetail.jsp").forward(request, response);
}
//使用符合条件的username查询出EPData和EPPostJob
//将ArrayList epds转化为json
JSONObject json = new JSONObject();
JSONArray array = new JSONArray();
JSONObject member = null;
if(usernames != null){
//创建EPDataDao数据库操作对象进行查找
EPDataDao epdd = new EPDataDao();
//创建EPPostJobDao数据库操作对象进行查找
EPPostJobDao eppjd = new EPPostJobDao();
for (String username : usernames) {
member = new JSONObject();
member.put("epUsername", username);
EPData epd = new EPData();
EPPostJob eppj = new EPPostJob();
try {
epd = epdd.getEPData(username);
member.put("epName", epd.getEPname());
member.put("epAddr", epd.getEPaddr());
} catch (SQLException e) {
e.printStackTrace();
}
try {
eppj = eppjd.getEPPostJob(username);
member.put("jobName", eppj.getJobname());
member.put("salary", eppj.getJobsalary());
} catch (SQLException e) {
e.printStackTrace();
}
array.add(member);
}
json.put("result", array);
PrintWriter pw = response.getWriter();
pw.print(json.toString());
}else{
System.out.println(false);
request.setAttribute("error", "未找到结果");
}
}
}
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//创建EPPostJob职位对象
EPPostJob eppj = new EPPostJob();
//创建EPPostJobDao职位要求数据库操作对象
EPPostJobDao eppjd = new EPPostJobDao();
//从session中获取企业用户名
HttpSession session = request.getSession();
String EPusername = (String) session.getAttribute("EPUser");
//从数据库中查找出该公司发布的职位要求
try {
eppj = eppjd.getEPPostJob(EPusername);
} catch (SQLException e) {
e.printStackTrace();
}
//将职位要求对象放入request中
request.setAttribute("EPPostJob", eppj);
if(eppj != null){
//将职位描述格式化字符串
StringBuilder sbJobdescribe = new StringBuilder();
sbJobdescribe = getFormatString(eppj.getJobdescribe());
request.setAttribute("jobdescribe", sbJobdescribe);
//将岗位职责格式化字符串
StringBuilder sbJobduty = new StringBuilder();
sbJobduty = getFormatString(eppj.getJobdescribe());
request.setAttribute("jobduty", sbJobduty);
//将技术要求格式化字符串
StringBuilder sbTechrequest = new StringBuilder();
sbTechrequest = getFormatString(eppj.getJobdescribe());
request.setAttribute("techrequest", sbTechrequest);
//处理公开权限状态
int status = eppj.getStatus();
if(status == 0){
request.setAttribute("auth", "(下架状态)");
}else{
request.setAttribute("auth", "(上架状态)");
}
}
//转向EPShowPostJob.jsp页面
request.getRequestDispatcher("../EPShowPostJob.jsp").forward(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 ServletException, IOException {
doGet(request,response);
}
}
/**
* 将数据库中原先的简历信息填写到表单中servlet,方便修改
*/
public class stuModifyResumeServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* 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
//转到stuShowStore.jsp页面
request.getRequestDispatcher("../stuShowStore.jsp").forward(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 {
}
}
/**
* 显示公司收藏的人servlet
*/
public class EPShowStoreServlet extends HttpServlet {
e1.printStackTrace();
}
//存入request
request.setAttribute("basicInfo", bi);
request.setAttribute("education", e);
request.setAttribute("jobIntention", ji);
//获得年龄
Calendar c = Calendar.getInstance();
int now = c.get(Calendar.YEAR);
c.setTime(bi.getBirthday());
int bir = c.get(Calendar.YEAR);
int age = now - bir;
request.setAttribute("age", age);
//对校内职务字符串eduduty进行处理
String eduDuty = e.getEduduty();
String[] eduDutys = eduDuty.split("\r\n");
StringBuilder sbDuty = new StringBuilder();
for(int i = 0;i < eduDutys.length; i++){
sbDuty.append(eduDutys[i].toCharArray());
sbDuty.append("<br>".toCharArray());
}
request.setAttribute("eduduty", sbDuty);
//对在校奖励字符串eduaward进行处理
String eduAward = e.getEduaward();
String[] eduAwards = eduAward.split("\r\n");
StringBuilder sbAward = new StringBuilder();
for(int i = 0;i < eduAwards.length; i++){
sbAward.append(eduAwards[i].toCharArray());
sbAward.append("<br>".toCharArray());
}
request.setAttribute("eduaward", sbAward);
//对社会实践字符串eduprictise进行处理
String eduPrictise = e.getEduprictise();
String[] eduPrictises = eduPrictise.split("\r\n");
StringBuilder sbPrictise = new StringBuilder();
for(int i = 0;i < eduPrictises.length;i++){
sbPrictise.append(eduPrictises[i]);
sbPrictise.append("<br>");
}
request.setAttribute("eduprictise", sbPrictise);
*/
public class StuResumeServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* 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 {
//创建简历基本信息、教育信息、求职意向对象
BasicInfo bi = new BasicInfo();
Education edu = new Education();
JobIntention ji = new JobIntention();
//创建各数据库操作对象
BasicInfoDao bid = new BasicInfoDao();
EducationDao ed = new EducationDao();
JobIntentionDao jid = new JobIntentionDao();
//从session中获得用户名
HttpSession session = request.getSession();
//从session中获取该公司的EPUser
HttpSession session = request.getSession();
String epUsername = (String) session.getAttribute("EPUser");
//查询出该公司收藏的公司
try {
arrStuUsername = epsd.queryEPStore(epUsername);
session.setAttribute("storeStuUsernames", arrStuUsername);
//判断是否为空
if(arrStuUsername.size() == 0){
//若为空
request.setAttribute("info", "您暂时无收藏的毕业生");
}else{
//创建EPSelectResult的list
ArrayList<EPSelectResult> arrEPsr = new ArrayList<EPSelectResult>();
//创建EPSelectResult对象
EPSelectResult epsr = null;
//创建BasicInfo和Education对象
BasicInfo bi = new BasicInfo();
Education e = new Education();
//创建BasicInfoDao和EducationDao对象
BasicInfoDao bid = new BasicInfoDao();
EducationDao ed = new EducationDao();
//查询出要显示的信息
for (String stuUsername : arrStuUsername) {
epsr = new EPSelectResult();
epsr.setStuUsername(stuUsername);
bi = bid.getBasicInfo(stuUsername);
epsr.setStuName(bi.getName());
epsr.setSex(bi.getSex());
e = ed.getEducation(stuUsername);
epsr.setSchool(e.getEduschool());
epsr.setMajor(e.getEdumajor());
arrEPsr.add(epsr);
}
//将arrEPsr放入request
request.setAttribute("stuUsers", arrEPsr);
}
} catch (SQLException e) {
e.printStackTrace();
}
//推荐功能
//若该公司收藏过毕业生
if(arrStuUsername.size() > 0){
//查询出收藏的毕业生的求职地点和求职类别
ArrayList<String> arrPlace = new ArrayList<String>();
ArrayList<String> arrTrade = new ArrayList<String>();
ArrayList<String> arrUsername = new ArrayList<String>();
try {
arrPlace = epsd.queryPlace(epUsername);
arrTrade = epsd.queryTrade(epUsername);
e.printStackTrace();
}
ssr.setJobaddr(epd1.getEPaddr());
ssr.setEPname(epd1.getEPname());
try {
eppj1 = eppjd.getEPPostJob(username);
} catch (SQLException e) {
e.printStackTrace();
}
ssr.setJobname(eppj1.getJobname());
ssr.setSalary(eppj1.getJobsalary());
arrRecommend.add(ssr);
}
request.setAttribute("recommends1", arrRecommend);
request.setAttribute("strRecommends1", arrRecommend.toString());
}
}
//转到stuShowStore.jsp页面
request.getRequestDispatcher("../stuShowStore.jsp").forward(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 {
}
}
/**
* 显示公司收藏的人servlet
*/
e.printStackTrace();
}
//转向EPHome.jsp页面
request.getRequestDispatcher("EPHomeServlet").forward(request, response);
}
}
public class EPHandleModifyData extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* 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
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
}
//判断密码是否是原密码
if(password.equals(epud.getEPpassword(username))){
//若密码和原密码一致,则可以进行修改密码操作
EPUser epu = new EPUser();
epu.setEPusername(username);
epu.setEPpassword(newpassword);
epud.updateEPUser(epu);
}else{
//若密码和原密码不一致,则跳转回原页面
request.setAttribute("error", "密码与原密码不一致");
request.getRequestDispatcher("../modifyPassword.jsp").forward(request, response);
return;
}
} catch (SQLException e) {
e.printStackTrace();
}
}else{
try {
//若用户为毕业生用户
StuUserDao sud = new StuUserDao();
//判断用户名是否在数据库中
if(!sud.isExist(username)){
//若用户名不在数据库中,则跳转回原页面
request.setAttribute("error", "用户名不存在");
request.getRequestDispatcher("../modifyPassword.jsp").forward(request, response);
return;
}
//判断密码是否为原密码
if(password.equals(sud.getPassword(username))){
//若密码和原密码一致,则继续进行修改密码操作
User u = new User();
u.setUsername(username);
u.setPassword(newpassword);
sud.updateUser(u);
}else{
//若密码和原密码不一致,则跳转会原页面
request.setAttribute("error", "密码和原密码不一致");
request.getRequestDispatcher("../modifyPassword.jsp").forward(request, response);
return;
}
} catch (SQLException e) {
e.printStackTrace();
*
* @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
* @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");
//从公司资料表单中获取各项信息
String EPname = request.getParameter("EPname");
String EPnature = request.getParameter("EPnature");
String EPcode = request.getParameter("EPcode");
String EPtrade = request.getParameter("EPtrade");
String EPscale = request.getParameter("EPscale");
String EPaddr = request.getParameter("EPaddr");
String EPcontact = request.getParameter("EPcontact");
String EPemail = request.getParameter("EPemail");
String EPtel = request.getParameter("EPtel");
String EPmobile = request.getParameter("EPmobile");
String EPpostalcode = request.getParameter("EPpostalcode");
String EPintroduction = request.getParameter("EPintroduction");
// System.out.println(EPname + " " + EPnature + " " + EPcode + " " + EPtrade + " " +
// EPscale + " " + EPaddr + " " + EPcontact + " " + EPemail + " " +
// EPtel + " " + EPmobile + " " + EPpostalcode);
//从session中取得公司用户名
HttpSession session = request.getSession();
String EPusername = (String) session.getAttribute("EPUser");
//创建公司资料对象
EPData epd = new EPData();
epd.setEPusername(EPusername);
epd.setEPname(EPname);
epd.setEPnature(EPnature);
epd.setEPcode(EPcode);
epd.setEPtrade(EPtrade);
doGet(request,response);
}
}
/**
* 查看简历servlet
*/
public class StuResumeServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* 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 class stuModifyResumeServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* 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 {
//创建简历基本信息、教育信息、求职意向对象
BasicInfo bi = new BasicInfo();
Education edu = new Education();
JobIntention ji = new JobIntention();
//创建各数据库操作对象
BasicInfoDao bid = new BasicInfoDao();
EducationDao ed = new EducationDao();
JobIntentionDao jid = new JobIntentionDao();
//从session中获得用户名
HttpSession session = request.getSession();
String username = (String) session.getAttribute("stuUser");
//从数据库中查找出简历信息
}
//存入request
request.setAttribute("basicInfo", bi);
request.setAttribute("education", e);
request.setAttribute("jobIntention", ji);
//获得年龄
Calendar c = Calendar.getInstance();
int now = c.get(Calendar.YEAR);
c.setTime(bi.getBirthday());
int bir = c.get(Calendar.YEAR);
int age = now - bir;
request.setAttribute("age", age);
//对校内职务字符串eduduty进行处理
String eduDuty = e.getEduduty();
String[] eduDutys = eduDuty.split("\r\n");
StringBuilder sbDuty = new StringBuilder();
for(int i = 0;i < eduDutys.length; i++){
sbDuty.append(eduDutys[i].toCharArray());
sbDuty.append("<br>".toCharArray());
}
request.setAttribute("eduduty", sbDuty);
//对在校奖励字符串eduaward进行处理
String eduAward = e.getEduaward();
String[] eduAwards = eduAward.split("\r\n");
StringBuilder sbAward = new StringBuilder();
for(int i = 0;i < eduAwards.length; i++){
sbAward.append(eduAwards[i].toCharArray());
sbAward.append("<br>".toCharArray());
}
request.setAttribute("eduaward", sbAward);
//对社会实践字符串eduprictise进行处理
String eduPrictise = e.getEduprictise();
String[] eduPrictises = eduPrictise.split("\r\n");
StringBuilder sbPrictise = new StringBuilder();
for(int i = 0;i < eduPrictises.length;i++){
sbPrictise.append(eduPrictises[i]);
sbPrictise.append("<br>");
}
request.setAttribute("eduprictise", sbPrictise);
//对自我评价字符串evaluation进行处理
String evaluation = ji.getEvaluation();
char[] evaluations = evaluation.toCharArray();
}
//判断密码是否是原密码
if(password.equals(epud.getEPpassword(username))){
//若密码和原密码一致,则可以进行修改密码操作
EPUser epu = new EPUser();
epu.setEPusername(username);
epu.setEPpassword(newpassword);
epud.updateEPUser(epu);
}else{
//若密码和原密码不一致,则跳转回原页面
request.setAttribute("error", "密码与原密码不一致");
request.getRequestDispatcher("../modifyPassword.jsp").forward(request, response);
return;
}
} catch (SQLException e) {
e.printStackTrace();
}
}else{
try {
//若用户为毕业生用户
StuUserDao sud = new StuUserDao();
//判断用户名是否在数据库中
if(!sud.isExist(username)){
//若用户名不在数据库中,则跳转回原页面
request.setAttribute("error", "用户名不存在");
request.getRequestDispatcher("../modifyPassword.jsp").forward(request, response);
return;
}
//判断密码是否为原密码
if(password.equals(sud.getPassword(username))){
//若密码和原密码一致,则继续进行修改密码操作
User u = new User();
u.setUsername(username);
u.setPassword(newpassword);
sud.updateUser(u);
}else{
//若密码和原密码不一致,则跳转会原页面
request.setAttribute("error", "密码和原密码不一致");
request.getRequestDispatcher("../modifyPassword.jsp").forward(request, response);
return;
}