欢迎来到天天文库
浏览记录
ID:867750
大小:91.53 KB
页数:17页
时间:2017-09-21
《j2ee编程技术实验报告书》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、J2EE编程技术实验报告书专业:软件工程指导老师:罗翌陈学号:0800350114姓名:凌浩实验一JSP网页设计一、实验目的掌握J2EEJSP+Servlet+JavaBean开发模式开发JSP网页步骤;掌握该开发模式实现用户登录页面功能。二、实验环境PC系列微机,CPU2G以上,内存1G以上,WindowsXP,MyEclipse6.5以上。三、实验步骤1、创建ServletLoginServlet实现登录验证编写该Servlet实现登录验证并进行配置。2、创建login.jsp、admin.jsp、user.jsp这3个js
2、p的页面采用的JSP+JavaBean开发模式中相同。3、调试程序是否正常运行四、实验报告LoginServlet.java:packagecom.servlet;importjava.io.IOException;importjava.io.PrintWriter;importjavax.servlet.ServletException;importjavax.servlet.http.HttpServlet;importjavax.servlet.http.HttpServletRequest;importjavax.ser
3、vlet.http.HttpServletResponse;importcom.dao.UserDao;importcom.dao.UserDaoImpl;importcom.model.User;publicclassLonginServletextendsHttpServlet{publicLonginServlet(){super();}publicvoiddestroy(){super.destroy();}publicvoiddoGet(HttpServletRequestrequest,HttpServletResp
4、onseresponse)throwsServletException,IOException{}publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{Stringa="123";Useruser=newUser();user.setUsername(request.getParameter("username"));user.setUserpassword(request
5、.getParameter("password"));user.setRole(request.getParameter("role"));UserDaouserdao=newUserDaoImpl();if(userdao.login(user)){if(user.getRole().equals("admin")){request.getRequestDispatcher("Admin.jsp").forward(request,response);}else{request.getRequestDispatcher("Us
6、er.jsp").forward(request,response);}}else{request.setAttribute("errormessage","error");request.getRequestDispatcher("login.jsp").forward(request,response);}}publicvoidinit()throwsServletException{}}Login.jsp:<%@pagelanguage="java"import="java.util.*"contentType="text
7、/html;charset=gb2312"%><%Stringpath=request.getContextPath();StringbasePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
8、MyJSP'login.jsp'startingpage
此文档下载收益归作者所有