j2ee大作业
7苏州科技大学JAVA EE高级开发技术期末大作业报告

从设计思路、功能实现、模块架构以及核心代码等几个方面说明作业实现方案: 一.设计思路 1. login.jsp 页面是登录页面, 用户名和密码提交到 loginCl.JSP 页面, 此页面调用 UserService 的远程服务接口方法去检查数据库 Users 表中是否匹配,checkUser 的数据库是使用配置数据源 jndi 的方式查找的,这是本项目中唯一一次使用 Webservice 和 jndi 的地方。匹配后提交到 WelServlet 页 面,不匹配就返回到登录页面重新登录。 2.WelServlet 得 到 Goods 商 品 表 第 一 页 的 所 有 信 息 , 具 体 的 实 现 是 调 用 GoodsBeanBO 类 , GoodsBeanBO 通过查询 Goods 表根据传入的 pageSize,得到 pageCount 再根据 pageNow 得到本页面所有 的商品信息存到 ArrayList 中,跳转到 Wel.jsp 页面。 3.Wel.jsp 是商品展示页面,根据 ArrayList 去展示每一件商品,根据 pageCount 去分页,每一件 商品可以加入购物车,页面上还有跳转到购物车列表的界面的链接。 4.Cart.jsp 是购物车界面,同样根据 pageNow,pageSize 去查询购物车展示到界面,每一件购物 车中的商品可以加一但是加到商品所库存的最大数时商品数就不会再增长了,每件商品还可以减一减 到最后商品就被删除了,每件商品还可以删除,页面上还展示有所有商品的总价钱,页面上还有跳转 到商品信息列表的界面去继续购物。 5.对商品 表的增删改 是 CartClServlet 通过调 用 CartBeanBO 去具体 实现对 Cart 表的操 作, CartClServlet 根据 request 每次传入的 flag 参数去选择不同的操作,传入所有信息到 Wel.jsp 去展 示 6.Login 。 Jsp 页 面 中 的 注 册 链 接 跳 转 到 addUser.jsp 页 面 。 Username 和 passwd 参 数 传 到 RegisterUserServlet 调用 UserBeanCL 的 registerUser 方法去注册。 二.模块架构 1.login.jsp loginCL.jsp 调用远程 Service 去登录 WelCLServlet 默认展示第一页商品列表
j2ee大作业

j2ee大作业J2EE论文考核大作业学校:院系:信息技术学院专业:计算机科学与技术姓名:学号:指导老师:一.在以Java技术为基础的Web开发中,前端开发包含哪些技术,后端开发包含哪些技术,各有何特点。
详细论述。
答:前端开发:前端开发技术CSS、HTML、javascript1、CSS目前最新版本为CSS3,是能够真正做到网页表现与内容分离的一种样式设计语言CSS能够对网页中的对象的位置排版进行像素级的精确控制,支持几乎所有的字体字号样式,拥有对网页对象和模型样式编辑的能力,并能够进行初步交互设计,是目前基于文本展示最优秀的表现设计语言。
CSS能够根据不同使用者的理解能力,简化或者优化写法,针对各类人群,有较强的易读性。
2、HTML(Hyper Text Mark-up Language )即超文本标记语言,是 WWW 的描述语言,由 Tim Berners-lee提出。
设计 HTML 语言的目的是为了能把存放在一台电脑中的文本或图形与另一台电脑中的文本或图形方便地联系在一起,形成有机的整体,人们不用考虑具体信息是在当前电脑上还是在网络的其它电脑上。
这样,你只要使用鼠标在某一文档中点取一个图标,Internet就会马上转到与此图标相关的内容上去,而这些信息可能存放在网络的另一台电脑中。
HTML文本是由 HTML命令组成的描述性文本,HTML 命令可以说明文字、图形、动画、声音、表格、链接等。
HTML 的结构包括头部 (Head)、主体 (Body) 两大部分。
头部描述浏览器所需的信息,主体包含所要说明的具体内容。
3、JavaScript一种直译式脚本语言,是一种动态类型、弱类型、基于原型的语言,内置支持类型。
它的解释器被称为JavaScript引擎,为浏览器的一部分,广泛用于客户端的脚本语言,最早是在HTML(标准通用标记语言下的一个应用)网页上使用,用来给HTML网页增加动态功能。
后端开发:Java语言体系比较庞大,包括多个模块。
J2EE大作业

武汉轻工大学数学与计算机学院2019-2020学年第一学期J2EE大作业指导老师: ******** 专业:信息管理与信息系统班级:信管1602班学号: ********** 姓名: *****2019年10月29 日1. 架构概述J2EE体系包括java server pages(JSP) ,java SERVLET, enterprise bean,WEB service等技术。
这些技术的出现给电子商务时代的WEB应用程序的开发提供了一个非常有竞争力的选择。
怎样把这些技术组合起来形成一个适应项目需要的稳定架构是项目开发过程中一个非常重要的步骤。
完成这个步骤可以形成一个主要里程碑基线。
形成这个基线有很多好处:各种因数初步确定为了形成架构基线,架构设计师要对平台(体系)中的技术进行筛选,各种利弊的权衡。
往往架构设计师在这个过程中要阅读大量的技术资料,听取项目组成员的建议,考虑领域专家的需求,考虑赞助商成本(包括开发成本和运行维护成本)限额。
一旦架构设计经过评审,这些因数初步地就有了在整个项目过程中的对项目起多大作用的定位。
定向技术培训一旦架构师设计的架构得到了批准形成了基线,项目开发和运行所采用的技术基本确定下来了。
众多的项目经理都会对预备项目组成员的技术功底感到担心;他们需要培训部门提供培训,但就架构师面对的技术海洋,项目经理根本就提不出明确的技术培训需求。
怎不能够对体系中所有技术都进行培训吧!有了架构里程碑基线,项目经理能确定这个项目开发会采用什么技术,这是提出培训需求应该是最精确的。
不过在实际项目开发中,技术培训可以在基线确定之前与架构设计并发进行。
角色分工有了一个好的架构蓝图,我们就能准确划分工作。
如网页设计,JSP 标签处理类设计,SERVLET 设计,session bean设计,还有各种实现。
这些任务在架构蓝图上都可以清晰地标出位置,使得项目组成员能很好地定位自己的任务。
一个好的架构蓝图同时也能规范化任务,能很好地把任务划分为几类,在同一类中的任务的工作量和性质相同或相似。
JAVA J2EE大作业——学生信息管理系统

JA V A & J2EE大作业——学生信息管理系统/src/beanFind.javapackage bean;import java.io.File;import java.io.IOException;import java.util.Iterator;import javax.servlet.jsp.JspWriter;import org.dom4j.Document;import org.dom4j.DocumentException;import org.dom4j.Element;import org.dom4j.io.SAXReader;public class Find {public String[] find(String id,String name,JspWriter out,String studentInfoPath) throws DocumentException, IOException{SAXReader saxReader = new SAXReader();Document document = saxReader.read(new File(studentInfoPath));Element root = document.getRootElement();String[]str=new String[7];int j=0;//遍历根结点(students)的所有孩子节点(肯定是student节点)boolean flagid,flagname;for ( Iterator<?> iter = root.elementIterator(); iter.hasNext(); ){out.print("<tr>");int i=0;Element element = (Element) iter.next();flagid=false;flagname=false;//遍历student结点的所有孩子节点(即id,name,age,gender,email,java),并进行处理Iterator<?> iterInner = element.elementIterator();Element elementInner = (Element) iterInner.next();if(elementInner.getText().equals(id)){flagid=true;}elementInner = (Element) iterInner.next();if(elementInner.getText().equals(name)){flagname=true;}if(id!=null&&name!=null){if(flagid&&flagname){j++;for ( Iterator<?> iterInner1 = element.elementIterator(); iterInner1.hasNext(); ){Element elementInner1 = (Element) iterInner1.next();str[i]=elementInner1.getText();out.print("<th>"+elementInner1.getText()+"</th>");i++;}break;}}else if(name!=null&&id==null){if(flagname){j++;for ( Iterator<?> iterInner1 = element.elementIterator(); iterInner1.hasNext(); ){Element elementInner1 = (Element) iterInner1.next();str[i]=elementInner1.getText();out.print("<th>"+elementInner1.getText()+"</th>");i++;}}}else if(id!=null&&name==null){if(flagid){j++;for ( Iterator<?> iterInner1 = element.elementIterator(); iterInner1.hasNext(); ){Element elementInner1 = (Element) iterInner1.next();str[i]=elementInner1.getText();out.print("<th>"+elementInner1.getText()+"</th>");i++;}break;}}else{break;}out.print("</tr>");}str[6]=j+"";return str;}}ReadUserInfo.javapackage bean;import java.io.IOException;import java.io.BufferedReader;import java.io.File;import java.io.FileReader;import java.util.LinkedList;public class ReadUserInfo {//文件中读取出的用户信息LinkedList<String> nameList = new LinkedList<String>();LinkedList<String> passList = new LinkedList<String>();// StringTokenizer相关变量String temp;String[] st;//用来保存用户输入信息String username;String password;public String getUsername(){return username;}public void setUsername(String username){ername = username;}public String getPassword(){return password;}public void setPassword(String password){this.password = password;}public LinkedList<String> getNameList(){return nameList;}public LinkedList<String> getPassList(){return passList;}public void read(String path) throws IOException{File file = new File(path);BufferedReader br = new BufferedReader(new FileReader(file));while ((temp = br.readLine()) != null){st =temp.split(",");nameList.add(st[0]);passList.add(st[1]);}}public boolean checknp(String name,String pass){LinkedList<String> nlist = getNameList();LinkedList<String> plist = getPassList();if(!nlist.contains(name) || !plist.contains(pass)){return false;}if(nlist.indexOf(name) != plist.indexOf(pass)){return false;}return true;}}XmlPage.javapackage bean;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.util.Iterator;import java.util.List;import javax.servlet.jsp.JspWriter;import org.dom4j.Document;import org.dom4j.DocumentException;import org.dom4j.Element;import org.dom4j.io.OutputFormat;import org.dom4j.io.SAXReader;import org.dom4j.io.XMLWriter;public class XmlPage {public void Edit(String user,String Id,String Name,String Age,String Gender,String Email,String Java,String studentInfoPath) throws DocumentException, IOException {SAXReader reader = new SAXReader();Document document = reader.read(new File(studentInfoPath));Element root = document.getRootElement();Element element = null ;for ( Iterator<?> iter = root.elementIterator(); iter.hasNext(); ){element = (Element) iter.next();//遍历student结点的所有孩子节点(即id,name,age,gender,email,java),并进行处理Iterator<?> iterInner = element.elementIterator();Element elementInner = (Element) iterInner.next();if(elementInner.getText().equals(user))break;}if(!Id.isEmpty())element.element("id").setText(Id);if(!Name.isEmpty())element.element("name").setText(Name);if(!Age.isEmpty())element.element("age").setText(Age);if(!Gender.isEmpty())element.element("gender").setText(Gender);if(!Email.isEmpty())element.element("email").setText(Email);if(!Java.isEmpty())element.element("java").setText(Java);OutputFormat out = new OutputFormat(" ", true, "utf-8");XMLWriter writer = new XMLWriter(new FileOutputStream(studentInfoPath),out);writer.write(document);writer.close();}public boolean check(String id,String studentInfoPath) throws DocumentException{SAXReader reader = new SAXReader();Document document = reader.read(new File(studentInfoPath));Element root = document.getRootElement();boolean flag=true;for ( Iterator<?> iter = root.elementIterator(); iter.hasNext(); ){Element element = (Element) iter.next();//遍历student结点的所有孩子节点(即id,name,age,gender,email,java),并进行处理Iterator<?> iterInner = element.elementIterator();Element elementInner = (Element) iterInner.next();if(elementInner.getText().equals(id)){flag=false;break;}}return flag;}public void add(String Id,String Name,String Age,String Gender,String Email,String Java,String studentInfoPath) throws Exception {SAXReader reader = new SAXReader();Document document = reader.read(new File(studentInfoPath));Element root = document.getRootElement();Element parent = root.addElement("student");Element id= parent.addElement("id");id.setText(Id);Element name = parent.addElement("name");name.setText(Name);Element age= parent.addElement("age");age.setText(Age);Element gender = parent.addElement("gender");gender.setText(Gender);Element email = parent.addElement("email");email.setText(Email);Element java = parent.addElement("java");java.setText(Java);OutputFormat out = new OutputFormat(" ", true, "utf-8");XMLWriter writer = new XMLWriter(new FileOutputStream(studentInfoPath),out);writer.write(document);writer.close();}public void Del(String id,String studentInfoPath) throws Exception {SAXReader reader = new SAXReader();Document document = reader.read(new File(studentInfoPath));Element root = document.getRootElement();Element element = null ;for ( Iterator<?> iter = root.elementIterator(); iter.hasNext(); ){element = (Element) iter.next();//遍历student结点的所有孩子节点(即id,name,age,gender,email,java),并进行处理Iterator<?> iterInner = element.elementIterator();Element elementInner = (Element) iterInner.next();if(elementInner.getText().equals(id))break;}root.remove(element);OutputFormat out = new OutputFormat(" ", true, "utf-8");XMLWriter writer = new XMLWriter(new FileOutputStream(studentInfoPath), out);writer.write(document);writer.close();}public void Reader(int diPage,int pageFileSize,JspWriter out,String studentInfoPath) throws DocumentException, IOException{SAXReader saxReader = new SAXReader();Document document = saxReader.read(new File(studentInfoPath));Element root = document.getRootElement();// 用于记录学生编号的变量int num=0;//遍历根结点(students)的所有孩子节点(肯定是student节点)for ( Iterator<?> iter = root.elementIterator(); iter.hasNext(); ){out.print("<tr>");num++;Element element = (Element) iter.next();if(num>=(diPage*pageFileSize-(pageFileSize-1))&&num<=diPage*pageFileSize){//遍历student结点的所有孩子节点(即id,name,age,gender,email,java),并进行处理for ( Iterator<?> iterInner = element.elementIterator(); iterInner.hasNext(); ){Element elementInner = (Element) iterInner.next();out.print("<th>"+elementInner.getText()+"</th>");}}out.print("</tr>");}}public int Count(String studentInfoPath) throws DocumentException{SAXReader saxReader = new SAXReader();Document document = saxReader.read(new File(studentInfoPath));List<?> list = document.selectNodes("/students/student");int num = list.size();return num;}}/src/filterAuthorityFilter.javapackage filter;import java.io.*;import javax.servlet.*;import javax.servlet.http.*;public class AuthorityFilter implements Filter{//FilterConfig可用于访问Filter的配置信息private FilterConfig config;//实现初始化方法public void init(FilterConfig config){this.config = config;}//实现销毁方法public void destroy(){this.config = null;}//执行过滤的核心方法public void doFilter(ServletRequest request,ServletResponse response, FilterChain chain)throws IOException,ServletException{//---------下面代码用于对用户请求执行预处理---------//获取ServletContext对象,用于记录日志ServletContext context = this.config.getServletContext();long before = System.currentTimeMillis();System.out.println("开始过滤...");//获取该Filter的配置参数String encoding = config.getInitParameter("encoding");String loginPage = config.getInitParameter("loginPage");String loginServlet = config.getInitParameter("loginServlet");String addsuccess = config.getInitParameter("addsuccess");String changePage = config.getInitParameter("changePage");String changesuccess = config.getInitParameter("changesuccess");String delete = config.getInitParameter("delete");//设置request编码用的字符集request.setCharacterEncoding(encoding);HttpServletRequest requ = (HttpServletRequest)request;HttpSession session = requ.getSession(true);//输出提示信息System.out.println("Filter已经截获到用户的请求的地址:" +requ.getServletPath());System.out.println("user:" +session.getAttribute("user"));//获取客户请求的页面String requestPath = requ.getServletPath();//如果session范围的user为null,即表明没有登录//且用户请求的既不是登录页面,也不是处理登录的页面if( session.getAttribute("user") == null&& !requestPath.endsWith(loginPage)&& !requestPath.endsWith(loginServlet)){request.setAttribute("tip", "nologin");request.getRequestDispatcher("/login.jsp").forward(request, response);}/*else if(requestPath.endsWith(addsuccess)||requestPath.endsWith(changePage)||requestPath.endsWith(changesuccess)||requestPath.endsWith(delete)){request.setAttribute("tip", "stop");request.getRequestDispatcher("/studentInfoDisplay.jsp").forward(request, response);}*///"放行"请求else{chain.doFilter(request, response);}//---------下面代码用于对服务器响应执行后处理---------long after = System.currentTimeMillis();//输出提示信息System.out.println("过滤结束");//输出提示信息System.out.println("请求被定位到" + ((HttpServletRequest) request).getRequestURI() +" 所花的时间为: " + (after - before));System.out.println("Session.tip:"+session.getAttribute("tip"));System.out.println("er:"+session.getAttribute("user"));}}/src/sevrvletLoginServlet.javapackage sevrvlet;import java.io.IOException;import java.io.PrintWriter;import javax.mail.Session;import javax.servlet.RequestDispatcher;import javax.servlet.ServletContext;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import org.jboss.weld.context.SessionContext;import bean.ReadUserInfo;public class LoginServlet extends HttpServlet {/*** Constructor of the object.*/public LoginServlet() {super();}/*** Destruction of the servlet. <br>*/public void destroy() {super.destroy(); // Just puts "destroy" string in log// Put your code here}/*** 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 {ReadUserInfo r = new ReadUserInfo();r.read(request.getSession().getServletContext().getRealPath("")+"\\WEB-INF\\users.txt");String username = request.getParameter("username");String password = request.getParameter("password");HttpSession session = request.getSession(true);//RequestDispatcher dis = null;PrintWriter out = response.getWriter();if(!r.checknp(username,password)){out.print("<script>alert('Wrong username or password');location.href='../login.jsp';</script>");//dis = request.getRequestDispatcher("../login.jsp");}else{session.setAttribute("user", username);System.out.println("LoginServlet tip:"+session.getAttribute("tip"));//out.print("<script>alert('z!');location.href='../index.jsp';</script>");//dis = request.getRequestDispatcher("../studentInfoDisplay.jsp");out.print("<script>location.href='../studentInfoDisplay.jsp';</script>");}//dis.forward(request, response);}/*** Initialization of the servlet. <br>** @throws ServletException if an error occurs*/public void init() throws ServletException {// Put your code here}}/src/tagIteratorTag.javapackage tag;import java.io.IOException;import java.util.Collection;import javax.servlet.jsp.JspException;import javax.servlet.jsp.tagext.SimpleTagSupport;public class IteratorTag extends SimpleTagSupport {private String collection;private String item;//collection的setter与getter函数public void setCollection(String conllection){this.collection = conllection;}public String getCollection(){return this.collection;}//item的setter与getter函数public void setItem(String item){this.item = item;}public String getItem(){return item;}@Overridepublic void doTag() throws JspException, IOException {// TODO Auto-generated method stubCollection itemlist = (Collection)getJspContext().getAttribute(collection);for(Object itemTemp : itemlist){getJspContext().setAttribute(item, itemTemp);getJspBody().invoke(null);}}/srcmytaglib.tld<?xml version="1.0"encoding="GBK"?><taglib xmlns="/xml/ns/j2ee"xmlns:xsi="/2001/XMLSchema-instance"xsi:schemaLocation="/xml/ns/j2ee web-jsptaglibrary_2_0.xsd"version="2.0"><tlib-version>1.0</tlib-version><short-name>mytaglib</short-name><!-- 定义该标签库的URI --><uri>/mytaglib</uri><tag><!-- 定义标签名 --><name>iterator</name><!-- 定义标签处理类 --><tag-class>tag.IteratorTag</tag-class><!-- 定义标签体支持JSP脚本 --><body-content>scriptless</body-content><!-- 配置标签属性:collection --><attribute><name>collection</name><required>true</required><fragment>true</fragment></attribute><!-- 配置标签属性:item --><attribute><name>item</name><required>true</required><fragment>true</fragment></attribute></tag></taglib>/WebRootadd.jsp<%@page language="java"contentType="text/html; charset=GBK" pageEncoding="GBK"%><%@page import="java.io.*"%><!DOCTYPE html PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type"content="text/html; charset=GBK"><title>添加信息</title></head><body><%-- <% if(request.getAttribute("tip") != null && request.getAttribute("tip").equals("stop")){request.removeAttribute("tip");out.print("<script>alert('不能直接访问该网页');</script>");}%> --%><center><jsp:useBean id="testBean"class="bean.XmlPage"scope="page"/><form action = "addsuccess.jsp"method = "post">请输入学生信息:<br><br>姓 名:<input type= "text"name="name"style = "width = 165px;height = 22px;"value=""/><br><br>学 号:<input type= "text"name="id"style= "width = 165px;height = 22px;"value=""/><br><br>年 龄:<input type= "text"name="age"style = "width = 165px;height = 22px;"value=""/><br><br>性 别:<input type= "text"name="gender"style style = "width = 165px;height = 22px;"value=""/><br><br>email:<input type= "text"name="email"style= "width= 165px;height = 22px;"value=""/><br><br>java :<input type= "text"name="java"style= "width= 165px;height = 22px;"value=""/><br><br><input type="submit"value="添加"/> <a href="studentInfoDisplay.jsp">返回</a></form></center></body></html>addsuccess.jsp<%@page language="java"contentType="text/html; charset=GBK" pageEncoding="GBK"%><%@page import="java.io.*"%><!DOCTYPE html PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type"content="text/html; charset=GBK"><title>find</title></head><body><%//System.out.println("11213213");if(application.getAttribute("lock") == "true"){out.print("<script>alert('他人正在操作中');location.href='studentInfoDisplay.jsp';</script>");}else{application.setAttribute("lock", "true");}%><jsp:useBean id="testBean"class="bean.XmlPage"scope="page"/><%String Id=request.getParameter("id"),Name=request.getParameter("name"),Age=request.getParameter("age"),Gender=request.getParameter("gender"),Email=request.getParameter("email"),Java=request.getParameter("java");//Name= new String(Name.getBytes("ISO8859_1"), "GBK");//Gender= new String(Gender.getBytes("ISO8859_1"), "GBK");System.out.println(request.getRealPath("/WEB-INF/students.xml")) ;if(Id.isEmpty()||Name.isEmpty()||Age.isEmpty()||Gender.isEmpty() ||Email.isEmpty()||Java.isEmpty()){application.setAttribute("lock", "false");out.print("<script>alert('学生信息未填写完整!');location.href='add.jsp';</script>");}else{if(testBean.check(Id,request.getRealPath("/WEB-INF/students.xml"))) {testBean.add(Id, Name, Age, Gender, Email, Java,request.getRealPath("/WEB-INF/students.xml"));application.setAttribute("lock", "false");out.print("<script>alert('成功添加!');location.href='studentInfoDisplay.jsp';</script>");}else{application.setAttribute("lock", "false");out.print("<script>alert('该学生已存在!');location.href='add.jsp';</script>");}}%></body></html>change.jsp<%@page language="java"contentType="text/html; charset=GBK" pageEncoding="GBK"%><%@page import="java.io.*"%><!DOCTYPE html PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type"content="text/html; charset=GBK"><title>修改信息</title></head><body><%-- <% if(request.getAttribute("tip") != null && request.getAttribute("tip").equals("stop")){request.removeAttribute("tip");out.print("<script>alert('不能直接访问该网页');</script>");}%> --%><center><jsp:useBean id="testBean"class="bean.XmlPage"scope="page"/><form action = "changesuccess.jsp"method = "post"><!-- 并发操作安全性代码 --><%String id=session.getAttribute("id").toString(),name=session.getAttribute("name").toString(),age=session.getAttribute("age").toString(),gender=session.getAttribute("gender").toString(),email=session.getAttribute("email").toString(),java=session.getAttribute("java").toString();%>在要修改处输入修改后信息:<br><br>姓 名:<input type= "text"name="name"style= "width = 165px;height = 22px;"value=<%=name%>><br><br>学 号:<input type= "text"name="id"style = "width = 165px;height = 22px;"value=<%=id %>><br><br>年 龄:<input type= "text"name="age"style = "width = 165px;height = 22px;"value=<%=age %>><br><br>性 别:<input type= "text"name="gender"style = "width = 165px;height = 22px;"value=<%=gender%>><br><br>email:<input type= "text"name="email"style= "width= 165px;height = 22px;"value=<%=email%>><br><br>java :<input type= "text"name="java"style= "width=165px;height = 22px;"value=<%=java%>><br><br><input type="submit"value="更改"/> <a href="studentInfoDisplay.jsp">返回</a></form></center></body></html>changesuccess.jsp<%@page language="java"contentType="text/html; charset=GBK" pageEncoding="GBK"%><%@page import="java.io.*"%><!DOCTYPE html PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type"content="text/html; charset=GBK"> <title>find</title></head><body><%System.out.println("11213213");if(application.getAttribute("lock") == "true"){out.print("<script>alert('他人正在操作中');location.href='change.jsp';</script>");}else{application.setAttribute("lock", "true");}%><jsp:useBean id="testBean"class="bean.XmlPage"scope="page"/><%String user=session.getAttribute("id").toString();String Id=request.getParameter("id"),Name=request.getParameter("name"),Age=request.getParameter("age"),Gender=request.getParameter("gender"),Email=request.getParameter("email"),Java=request.getParameter("java");//Name= new String(Name.getBytes("ISO8859_1"), "GBK");//Gender= new String(Gender.getBytes("ISO8859_1"), "GBK");%><%if(!Id.equals(user)){if(testBean.check(Id,request.getRealPath("/WEB-INF/students.xml"))) {testBean.Edit(user,Id, Name, Age, Gender, Email, Java,request.getRealPath("/WEB-INF/students.xml"));application.setAttribute("lock", "false");out.print("<script>alert('成功更改!');location.href='studentInfoDisplay.jsp';</script>");}else{application.setAttribute("lock", "false");out.print("<script>alert('该学生已存在!');location.href='change.jsp';</script>");}}else{testBean.Edit(user,Id, Name, Age, Gender, Email, Java,request.getRealPath("/WEB-INF/students.xml"));application.setAttribute("lock", "false");out.print("<script>alert('成功更改!');location.href='studentInfoDisplay.jsp';</script>");}%></body></html>delete.jsp<%@page language="java"contentType="text/html; charset=GBK" pageEncoding="GBK"%><%@page import="java.io.*"%><!DOCTYPE html PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type"content="text/html; charset=GBK"><title>删除</title></head><body><%if(application.getAttribute("lock") == "true"){out.print("<script>alert('他人正在操作中');location.href='studentInfoDisplay.jsp';</script>");}else{application.setAttribute("lock", "true");}%><jsp:useBean id="testBean"class="bean.XmlPage"scope="page"/><%String id=session.getAttribute("id").toString();%><%testBean.Del(id,request.getRealPath("/WEB-INF/students.xml")); %><%application.setAttribute("lock", "false");out.print("<script>alert('成功删除!');location.href='studentInfoDisplay.jsp';</script>");%></body></html>find.jsp<%@page language="java"contentType="text/html; charset=GBK" pageEncoding="GBK"%><%@page import="java.io.*"%><!DOCTYPE html PUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN" "/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type"content="text/html; charset=GBK"><title>查找</title></head><body><%-- <% if(request.getAttribute("tip") != null &&。
【精品】网上书店j2ee大作业

上海xxxxxx JavaEE课程大作业题目基于B/S结构的网上书店的设计与实现学号2008XXXX课号130501905姓名XXXX班级2008XXX院系计信专业软件工程2010-12—27目录第一章引言1.1研究背景国外的Web商务系统应用起步较早,所以应用的领域比较广,网络销售已经在人们日常消费中占到一定比例,Web商务系统也比较成熟。
人们可以以网络这个媒体,足不出户就可以搜索、查询到自己需要的信息、购买自己需要的商品。
我国电子商务的发展起源于70年代的EDI应用,我国海关是最早引入EDI进行报关,经过几年的完善发展目前企业可以通过上网申请报关。
电子商务概念首次引入中国是在1993年,第一笔网上交易发生在1996年。
目前我国网上书店的主要类型有:由国有新华书店投资建设的网上书店.一些有实力的传统书店,都会建立自己的网站,利用网络促销,争取更多的市场份额。
它们主要依托传统的图书大厦的图书储存进行网络售书,属于新华书店上网或上网的书店。
由出版社建立的网上书店。
因为网络出版的缘故,出版社是最早触网的,我国500多家出版社中,已建立网站的有349家,占62%.较好的出版社营销网站建设的特点是:以出版社本社出版物为网站核心,突出特色,访问速度快捷,信息及时更新,内容的合理编排以及完善的检索能力,较强的交互能力。
外贸出版公司投资建设的网上书店。
这一类网上书店立足公司主营业务,主要对海外进行图书销售,销售量逐渐增加.非出版业资本投资建设的网上书店。
如卓越网。
就目前情况而言,上述几类的网络书店可以分为两大类。
一类是没有实体书店的网上书店,以卓越网为代表,还有一类是以实体书店为支撑的。
在这个背景之下,我开发了网上书店管理系统,形成了以计算机技术、网络技术、以及数据库技术等有机地结合起来的网上书店管理系统。
充分利用网络技术、数据库技术和管理技术相互结合具有的优越性,将书店管理移置到互联网环境中进行,使书店更能有效的工作,完成各种任务,如网上购书,网上看书等一切依托上网的网上购物平台。
J2EE期末复习(含答案)

1、ORM 有什么好处?AA).能进行关系对象的映射B).具有控制器功能C).能在服务器端保存客户端状态D).向DTO传递数据2、在使用property标签时,如果要显示标签的代码,需要设置下面哪个属性的属性值? CA).defaultB).valueC).escapeD).id3、以下哪一种检索策略利用了外连结查询?CA).立即检索B).延迟检索C).迫切左外连结检索D).迫切右外连结检索4、如果你不能确定你要寻找的对象的持久化标识符,那么你需要使用查询,使用Session 的什么方法? AA).createQuery()B).query()C).queryAll()D).queryObject()5、HQL查询语句from Cat as cat,不仅仅返回Cat的实例,而且还返回____的实例。
BA).Cat 父类B).Cat 子类C).Cat 实现接口D).Cat 兄弟类6、下面哪些子句不支持算数表达式?CA).compute by 和order byB).compute by 和insert byC).order by 和group byD).insert by 和group by7、使用Hibernate 的QBC 查询,要使用SQL 中的类似select count(*) from tablename 方法求出记录数,必须使用哪一个类?BA).RestrictionsB).ProjectionsC).CriteriaD).Criteron8、Struts2中默认的主题是哪一种?BA).simpleB).xhtmlC).css_xhtmlD).ajax9、在Hibernate 中,关于数据库的方言,下面哪个说法是正确的?DA).可以不写数据库方言B).数据库方言没有作用,可以随便写C).有通用的数据库方言可以使用D).数据方言对应于每个数据库,主要用于产生SQL 语句数据方言对应于每个数据库10、在JEE企业级开发中,SSH框架中Struts主要是完成Web的MVC中的哪个角色?AA).C(控制器)和V(视图)B).M (模型)和C(控制器)C).只有C(控制器)D).V(视图)和M(模型)11、在Struts2的包配置中,下面哪个属性是必须指定的?CA).namespaceB).extendsC).nameD).abstract12、通过实现下面哪个接口,可以很容易地实现一个拦截器类的编写?BA).ActionB).InterceptorC).AbstractInterceptorD).MethodInterceptor13、Action运行期间所有用到的数据都保存在下面哪个对象中?DA).RequestB).SessionC).ResponseD).ActionContext14、在使用SSH进行JEE企业级开发中,通常把模板文件放置在/WEB-INF目录下的原因是?AA).因为模板文件不能直接访问,为了防止用户直接访问模板文件,所以放在/WEB-INF目录下,让这些文件直接访问不到。
J2EE作业步骤

<frameset cols="20%,*">
<frame src="left.jsp">
<frame src="right.jsp" name="right">
</frameset>
</frameset>
(4). 新建JSP命名为right.jsp(空白界面)
(5). 新建JSP命名为duInfo.jsp 使用Dreamweaver,打开duInfo.jsp
插入表格二行七列,输入内容:条形码,姓名,读者类型,证件类型,证件号码,电话,Email,保存。
在MyEclipse中拖入iterator,设置属性;<s:iterator id="al" value="#request.list">
3. 复制lib库包,将jar全部加入build path路径中
复制lib到src同级目录
右键单击工程名,Build path>Configure Build path…
选择Libraries,点击Add Enternal JARs…, 全选lib包,点击OK
4.添加数据库驱动,链接test,选择mircosoft-jtds驱动
Window>show view>other 输入DB,选中DB Browser
右键单击MyEclipse Derby>new
Driver template: Microsoft SQL Server(JTD)
j2ee开发习题和答案EJB,servlet

j2ee开发习题和答案EJB,servletQ :1Which of the following statements are correct regarding the stateful session beanSelect Your Answer :They allow PostConstruct, PreDestroy callback methods.A session bean has to always implement the intrefaces annotated with @Local and @Remote to Dspecify the local and and remote interfaces.A Session bean can have no Local interface.When a client looks up for a stateful session bean in JNDI, same bean instance is returned every time.Q :2GivenBean1 --> Stateful session Bean's local interface of 'bean1' Bean2 --> Stateless Session Bean's local interface of 'bean2' and given:@EJB(beanName="bean1") Bean1 ref1;@EJB(beanName="bean1") Bean1 ref2;@EJB(beanName="bean2") Bean2 ref3;@EJB(beanName="bean2") Bean2 ref4;After injection has completed, what would be the output of the following code?System.out.println(ref1.equals(ref2));System.out.println(ref3.equals(ref4));Select Your Answer :A falsefalseB falsetrueC truefalseD true trueQ :3EJB supports scheduling system called Timer Service.Which interface must implemented by an enterprise bean to be able to be scheduled ?Select Your Answer :A java.util.TimerB javax.util.TimerC javax.ejb.TimerD javax.ejb.TimerObjectE java.util.TimerObjectQ :4Which of the following stateless bean definitions are correct to be able to be scheduled?Select Your Answer :A import javax.ejb.*;@Statelesspublic ClassFoo implements FooRemote,TimedObject{public void ejbTimeout(Timer timer){//logic }}B import javax.ejb.*;@Statelesspublic class Foo implements FooRemote{@Timeoutpublic String ejbTimeout(Timer timer){ // logic }}C import javax.ejb.*;@Statelesspublic class Foo implements FooRemote{@Timeoutpublic void fnTimeout(Timer timer){ // logic }}D import javax.ejb.*;@Statelessublic class Foo implements FooRemote{@Timedoutpublic void fnTimeout(Timer timer){ // logic }}Q :6Given a Car EJB used to schedule perticular car for Maintenance, which is being scheduled as below : @Stateless public class Foo implements FooRemote{@Resource TimerService timerService;@Timeoutpublic void maintenanceCall(){// maintenance appropriate Logic}public void ScheduleMaintenance(Integer carId, Date dayToBeScheduled){timerService.createTimer( dayToBeScheduled, carId.toString());}public void resceduleMaintenance(Integer carId, Date rescheduleDate){//Block 1 }}What are the appropriate code to be inserted in //Block 1 to reschedule a car maintenance to a new time?Select Your Answer :A for(Ibject obj:TimerService.getTimers()){Timer timer = (Timer) obj;if(timer.getInfo().equals(carId.toString()){timer = timerService.createTimer(rescheduleDate,carId.toString);}}B for(Ibject obj:TimerService.getTimers()){Timer timer = (Timer) obj;if(timer.getInfo().equals(carId.toString()){timer.cancel();timerService.createTimer(rescheduleDate,carId.toString);}}C for(Ibject obj:TimerService.getTimers()){Timer timer = (Timer) obj;if(timer.getInfo().equals(carId.toString())timer.reschedule(rescheduleDate);}Timer timer = timerService.getTimer(carId);timer.reschedule(rescheduleDate);Q :7Given a Timer scheduled as below:Calendar time = Calendar.getInstance();time.add(Calendar.DATE,15);Date initialExpiration = Timer timer =timerService.createTimer(time.getTime(),1000*60*60*24,"Ti mer1");what will be the result of calling timer.getNextTimeout()?Select Your Answer :A The Date returned is the time when the timer will be off first time.B The Date returned is the time when timer is off next time.C The Date returned is the time remaining until the timer is off next time.D None of the aboveQ :9Given 2 Session beans, Foo and Foo1@Statelesspublic class Foo implementsFooRemote{private Foo1 foo1;@Resource TimerService timerService;@PostConstructpublic void init(){ // block 1 }@PreDestorypublic void finish(){ // block 2 }// business methodpublic void doBusinessAction(){ // block3 }@EJBpublic setFoo1(Foo1 foo1){//Block 4this.foo1 = foo1;}}Which are the legal blocks to place following code:timerService.createTimer(expDate,"test Timer");Select Your Answer :A block 1B block 2C block 3D block 4E block 5Q :10Which of the following statements about @PostConstruct callback method of an EJB are true?Select Your Answer :A It must return voidB It can or can't have parametersC It should not throw any checked exceptionsD It can define 0-n number of PostConstructcallback methodsE It should be a public method.(access modifier should be public)Q :11Which of the following statements about session beans are true?Select Your Answer :A A session bean can have no Local and Remote interfaces.B A session bean can have0 or more Local interfaces.C A session bean can have 0 or more remote interfaces.D An interface can be marked both as remote and local.Q :12Which of the following statements about EJB programming are true according to EJB Specs?Select Your Answer :A An EJB can declare,read and update static fieldsB EJB should not use java.io package in attempt to access files and directories in the file system.C EJB can listen to a socket or accept connections.D None of the aboveQ :13In EJB 3.0, the deployment descriptor in ejb-jar file (ejb-jar.xml) is optional.Select Your Answer :True FalseQ :14Which of the following statements about session beans are true?Select Your Answer :A.Session beans can't represent db dataB.Session beans can't access db dataC.Session beans are ususally used to define interaction between other beansD.Session beans usually contain business logic.E.Stateless session beans have longer life than stateful session beansQ :15Which of the following statements are true?Select Your Answer :A.Stateful session beans can have timeout period and remove methods.B.The stateless session beans can't have timeout period.C.Stateless session beans can have remove method.For Server, when client removes a stateless session bean, there is no effect.D.Stateful session beans are lightweigh and fast as they are associated with single client and there is no overhead of object swapping.E.Stateless sesiion bean can not have instance variables. They can only have static and final fields.Q :16Which of the following statements are true about remote and local interfaces of a sessionbean?Select Your Answer :A.Remote interfaces can also be marked as Local.B.If a client invokes a method on bean's remote interface, given the client and server are running in different VM, the parameter values and return values are passed by Value.(They are copied)C.If a client invokes a method on bean's remote interface, given the client and server are running on same VM, the parameter values and return values are passed by Reference.D.One can define a common base interface for Remote and Local interface if they share same methods.E.Entity Beans can be used as parametrs and Return values to remote and local interfaces.Q :17A session bean's remote method threw a EJBException. What doyou think might be the reasons? Select Your Answer :A.The session bean processing might have thrown a RuntimeExceptionB.The session bean processing might have thrown an Application Exception.C.The session bean might have thrown a checked Exception, which was caught and again wrapped into a EJBException.D.The container might have thrown some exceptionE.The session bean might have thrown a non RuntimeException.Q :18I have a session bean which expose different methods on local and remote business interfaces as below.public interface myAppBaseInterface{public void keepMeReady();}@Remotepublic interface myAppRemote extends myAppBaseInterface{public ResultObj calculateForRemoteClients();}@Localpublic interface myAppLocal myAppBaseInterface{public void calculateForLocalClients(ResultObj obj);}Recently, during enhancing the project,in keepMeReady() method, I had to call another session bean's method passing current session bean's own object reference.How can I determine through which interface the client has made the call? Select Your Answer :/doc/ad13944721.html,ing getBusinessObjectInterfae method of SessionContext./doc/ad13944721.html,ing getBusinessInterface method of sessionContext/doc/ad13944721.html,ing getInvokedEJBObjectInterface method of SessionContext /doc/ad13944721.html,ing getInvokedBusinessInterface method of SessionContextE.Get the Business EJB object using getBusinessInterface() method and use instanceof operator to determine the interface.Q :19Which of the following rules are true about session beans.Select Your Answer :A.Business methods must not be declared final or static.B.Arguments and return types for remote componentinterface methods must be legal RMI-IIOP types.C.One must not declare any application exceptions that were not declared in remote or local interfaces for that matching business method.D.The session bean class can be abstract but not final.E.The Bean class cant have superclasses.Q :21Which are the appropriate places for a stateless session bean to invoke getCallerPrincipal() method of sessionContext? Select Your Answer :A.In the constructorB.Inthe setter method marked @ResourceC.In Method marked @PostConstructD.in Method marked @PreDestroyE.In Business methodF.All the aboveQ :22Which are the appropriate places for a stateful session bean to invoke getCallerPrincipal() methodof sessionContext?Select Your Answer :A.In the constructorB.In the setter method marked as @ResourceC.in Method marked @PostConstructD.in Business methodE.in the finalize methodQ :23If a client makes call to a session bean object, which has been already removed by the container, which exception will be thrown?Select Your Answer :A.java.rmi.RemoteExceptionB.NullPointerExceptionC.EJBExceptionD.java.rmi.NoSuchObjectExceptionE.javax.ejb.ObjectNotFoundExceptionQ :24What happens if a stateless session bean throws a System Exception (RuntimeException)?Select Your Answer :A.The bean instance will be killed.B.The bean instance is returned to the pool.C.There is no effect on the bean instanceQ :25Which of the following statements are true about stateless session bean creation?Select Your Answer :A.Stateless session beans are created when client tries to get reference using its remote or local interface.B.The PostConstruct method of a stateless session bean will be called only once during its life cycle.C.When client invokes the business method, the stateless session bean will be pulled from pool.D.SessionContext's client specific methods can be accessed only when bean is executing its business method.Q :26Identify correct syntax of defining a bean's PostConstruct method?Select Your Answer :A.MyBeanmyinitB.MyBeanmyinitC.MyBeanmyinitD.MyBeanmyinitE.None of the aboveQ :27In case of session bean, that implements a web service, how to define a webservice interface?Select Your Answer :A.A web service interface is not required to be defined.B.A web service interface has to be marked as @WebServiceC.A web service interface method has to be marked as @WebMethodD.None of the above.Q :28In EJB 3, how can a client get reference to a session bean's remote or local interface?Select Your Answer :A.Through the dependency injectionB.By calling create method/doc/ad13944721.html,ing lookup mechanismD.Directly instantiating the beanQ :29Which of the following are correct statements about the Life Cycle Callback Methods for Stateful Session Beans?Select Your Answer :A.PostConstruct methods are invoked on the newly constructed instance, after any dependency injection has been performed by the container and before the first business method is invoked on the bean.B.PostConstruct methods are invoked in an unspecified transaction and security context.C.PreDestroy methods execute after any method, annotated with the Remove annotation has completed.D.PreDestroy methods are invoked in an unspecified transaction and security context.Q :30Given a session bean with following instance fields, which object can be successfully passivated and reactivated?@Resource SessionContext sessionContext;Socket cs;@EJB AnotherEJb myEjb;String description; java.sql.Connection conn;Select Your Answer :A.sessionContextB.csC. myEjbD.connE.StringQ :32A container may passivate a stateful session bean instance only when the instance is not in a transaction.Select Your Answer :A.TRUEB.FALSE, as the Transaction will end when called business method ends.Q :34A stateful session bean is involved in a transaction. The transaction has taken a long time, and reached the timeout period of the session bean. What willhappen to the session bean once the timeout period has crossed and the bean is still in the transaction?Select Your Answer :A.The transaction will be rolled back and instance will be discarded.B.The transaction will be stopped at that moment when bean timesout. All changes already done will be committed and the bean instance will be discarded.C.Timeout will not affect the transaction and session bean.D.It depends upon the vendor implementation.E.None of the aboveQ :35Which of the following statements about @PreDestroy method are true?Select Your Answer :A.This method should not return any valueB.The method can not have anyparametersC.A bean can have 0-n methods marked as @PreDestroyD.If a stateful Session bean is in method-ready-state and if it times out, the container always calls @Predestroy method before discarding the bean instance.E.If a client calls the method marked @Remove then on sessionbean then, after executing the Remove method container always calls @Predestroy method before discarding the bean instance.Q :37Which of the followingstatements are true about implementing javax.ejb.SessionSynchronization interface by session beans?Select Your Answer :A.This helps session beans to get synchronized with the http client's session.B.This helps session beans to synchronize their state withother session beans sharing same data.C.A stateless session bean cannot implement SessionSynchronization interface.D.None of the aboveQ :38Which of the following statements are true?Select Your Answer :A.When an extended persistence context is used inthe stateless session bean, the entities loaded will be active throughout bean's life.B.In the transaction scoped persistence context, theTransaction starts and ends within the scope of the method.C.If a bean has a definition as below:@PersistenceContext(unitName="test")then the persistence context is Extended.The stateful session bean can only use Extended persistence context.D.In the Extended persistence context, one need not required to call EntityManage.merge() call on entitiesQ :39Given 2 stateful session beans:Bean1and Bean2@Statefulpublic class Bean1 implements Bean1Remote,Bean1Local{@EJB Bean2Local bean2;@PersistenceContext(unitName="testdb",type="EXTENDED ")private EntityManager entityManager;}@Statefulpublic class Bean2 implements Bean2Remote,Bean2Local{@PersistenceContext(unitName="testdb",type="EXTENDED ")private EntityManager entityManager;}Which of the following statements are true?Select Your Answer :A.If Bean1 updates a db entity, Bean2's copy of the same entity will be discarded or detached.B. Its not legal to have EXTENDED context for same db by 2 session beans.C. In real when Bean1 gets instantiated and is in method-ready-state, both Bean1 and Bean2 instances share same persistence context.D.When Bean1 gets instantiated, a unique session will becreated for Bean2.E.If Bean1 times out, the Bean2 session will not be affected. This session remains in the server until Bean2 times out.Q :40Which of the following statements are true about InitialContext?Select Your Answer :A.This is the ejb bean's reference to get information from the container.B.How to get reference to InitialContext is vendor specific.C.InitialContext is used as particular 'node' on the JNDI virtual directory tree.D.InitialContext extends EJBContextE.InitialContext can be used to get reference to another Enterprise beanF.InitialContext can also be used to get deploy-time values for a bean, set by the deployerQ :41Which of the following events may cause a session bean to die?Select Your Answer :A.The client crashesB.The client calls method marked @RemoveC.The bean times outD.The bean throws System Exception1. What is wrong with the following code?( )public void doFilter(ServletRequest req, ServletResponse, res,FilterChain chain)throws ServletException, IOException { chain.doFilter(req, res);HttpServletRequest request = (HttpServletRequest)req;HttpSession session = request.getSession();if (session.getAttribute("login") == null) {session.setAttribute("login"”, new Login());}}a. The doFilter() method signature is incorrect; it should takeHttpServletRequest and HttpServletResponse.b. The doFilter() method should also throw FilterException.c. The call to chain.doFilter(req, res) should be this.doFilter(req, res,chain).d. Accessing the request after chain.doFilter() results in an IllegalStateException.e. Nothing is wrong with this filter.2. Which of the following code snippets, when inserted in the doGet() method, will correctly count the number of GET requests made by a user? ()a. HttpSession session = request.getSession();int count = session.getAttribute("count");session.setAttribute("count", count++);b. HttpSession session = request.getSession();int count = (int) session.getAttribute("count");session.setAttribute("count", count++);c. HttpSession session = request.getSession();int count = ((Integer) session.getAttribute("count")).intValue();session.setAttribute("count", count++);d. HttpSession session = request.getSession();int count = ((Integer) session.getAttribute("count")).intValue();session.setAttribute("count", new Integer(count++));3. GivenBean1 --> Stateful session Bean's local interface of 'bean1' Bean2 --> Stateless Session Bean's local interface of 'bean2' and given:@EJB(beanName="bean1") Bean1 ref1;@EJB(beanName="bean1") Bean1 ref2;@EJB(beanName="bean2") Bean2 ref3;@EJB(beanName="bean2") Bean2 ref4;After injection has completed, what would be the output of the following code? ( ) System.out.println(ref1.equals(ref2));System.out.println(ref3.equals(ref4));A. falseB. falseC. t rueD. truefalse true false true4. Assume that the following servlet mapping is defined in the deployment descriptorof a web application: TestServlet Which of the following requests will not be serviced by TestServlet?()a. /hello.aspb. /gui/hello.aspc. /gui/hello.asp/bye.aspd. /gui/*.aspe. /gui/sales/hello.aspf./gui/asp。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
J2EE论文考核大作业学校:院系:信息技术学院专业:计算机科学与技术姓名:学号:指导老师:一.在以Java技术为基础的Web开发中,前端开发包含哪些技术,后端开发包含哪些技术,各有何特点。
详细论述。
答:前端开发:前端开发技术CSS、HTML、javascript1、CSS目前最新版本为CSS3,是能够真正做到网页表现与内容分离的一种样式设计语言CSS能够对网页中的对象的位置排版进行像素级的精确控制,支持几乎所有的字体字号样式,拥有对网页对象和模型样式编辑的能力,并能够进行初步交互设计,是目前基于文本展示最优秀的表现设计语言。
CSS能够根据不同使用者的理解能力,简化或者优化写法,针对各类人群,有较强的易读性。
2、HTML(Hyper Text Mark-up Language )即超文本标记语言,是WWW 的描述语言,由Tim Berners-lee提出。
设计HTML 语言的目的是为了能把存放在一台电脑中的文本或图形与另一台电脑中的文本或图形方便地联系在一起,形成有机的整体,人们不用考虑具体信息是在当前电脑上还是在网络的其它电脑上。
这样,你只要使用鼠标在某一文档中点取一个图标,Internet就会马上转到与此图标相关的内容上去,而这些信息可能存放在网络的另一台电脑中。
HTML 文本是由HTML命令组成的描述性文本,HTML 命令可以说明文字、图形、动画、声音、表格、链接等。
HTML的结构包括头部(Head)、主体(Body) 两大部分。
头部描述浏览器所需的信息,主体包含所要说明的具体内容。
3、JavaScript一种直译式脚本语言,是一种动态类型、弱类型、基于原型的语言,内置支持类型。
它的解释器被称为JavaScript引擎,为浏览器的一部分,广泛用于客户端的脚本语言,最早是在HTML(标准通用标记语言下的一个应用)网页上使用,用来给HTML网页增加动态功能。
后端开发:Java语言体系比较庞大,包括多个模块。
从Web项目应用角度讲有JSP、Servlet、JDBC、JavaBean(Application)四部分技术(1)、Java Database Connectivity(JDBC)技术在Java Web应用开发中,数据库管理系统(RDBMS)的使用是不可缺少的。
JDBC(Java Database Connectivity) 是一种用于执行 SQL 语句的Java API。
它由一组用Java 编程语言编写的类和接口组成。
JDBC 为工具/数据库开发人员提供了一个标准的API,使他们能够用纯Java API 来编写数据库应用程序。
简单地说,JDBC 可做三件事:与数据库建立连接,发送 SQL 语句,处理结果。
(2)、Servlet技术Servlet是运行在服务器端的程序,可以被认为是服务器端的applet。
servlet被Web服务器(例如Tomcat)加载和执行,就如同applet被浏览器加载和执行一样。
servlet从客户端(通过Web服务器)接收请求,执行某种操作,然后返回结果。
(3)、JavaServer Pages(JSP)技术JSP是从Servlet上分离出来的一小部分,简化了开发,加强了界面设计。
JSP 定位在交互网页的开发。
运用Java语法,但功能较Servlet弱了很多,并且高级开发中只充当用户界面部分。
JSP容器收到客户端发出的请求时,首先执行其中的程序片段,然后将执行结果以HTML格式响应给客户端(4)、JavaBean(Application)应用组件技术Application是Java应用程序,在WEB项目和一些开发中主要应用JavaBean。
它就是Application的一部分,逻辑运算能力很强,能极大的发挥Java语言的优点。
二.Java Web开发在使用Servlet/JSP在开发时,Servlet和JSP 应各自侧重于哪些部分,用MVC的观点阐述。
答:JSP全名为Java Server Pages,中文名叫java服务器页面,其根本是一个简化的Servlet设计JSP技术有点类似ASP技术,它是在传统的网页HTML (标准通用标记语言的子集)文件(*.htm,*.html)中插入Java程序段(Scriptlet)和JSP标记(tag),从而形成JSP文件,后缀名为(*.jsp)。
用JSP开发的Web应用是跨平台的,既能在Linux下运行,也能在其他操作系统上运行servlet是在服务器上运行的小程序。
这个词是在Java applet的环境中创造的,Java applet 是一种当作单独文件跟网页一起发送的小程序,它通常用于在客户端运行,结果得到为用户进行运算或者根据用户互作用定位图形等服务。
Jsp是Servlet技术的扩展,本质上是Servlet的建议方式,更强调应用的外表表达。
JSP编译后是“类Servlet”。
Servlet和JSP最主要的不同点在于,Servlet的应用逻辑实在Java文件中,并且完全从表示层中的HTML里分离开来。
而JSP的情况是Java的HTNL可以组合成一个扩展名为.jsp的文件。
JSP 侧重于试图,Servlet主要用于控制逻辑。
JSP和Servlet的本质都是Java类。
三.java Web开发时,页面的请求转发和重定向各自是指什么?它们有哪些异同之处。
答:请求转发:是服务器内部把对一个request/response的处理权,移交给另外一个对于客户端而言,它只知道自己最早请求的那个A,而不知道中间的B,甚至C、D。
传输的信息不会丢失。
重定向:其实是两次request, 第一次,客户端request A,服务器响应,并response回来,告诉浏览器,你应该去B。
这个时候IE可以看到地址变了,而且历史的回退按钮也亮了。
重定向可以访问自己web应用以外的资源。
在重定向的过程中,传输的信息会被丢失。
不同之处:(1)请求转发是一次请求一次响应,而重定向是两次请求两次响应;(2)请求转发地址栏不会改变,而重定向地址栏会显示第二次请求的地址;(3)请求转发只能转发给本项目的其他资源,而重定向不仅可以重定向到本项目的其他资源,还可以重定向到其他项目;(4)请求转发是服务器端的行为,转发时只需要给出转发的资源路径即可,如Se rvlet的访问路径;而重定向需要给出全路径,即路径要包含项目名;(5)请求转发比重定向的效率高,因为请求转发是一个请求。
在以后的开发中,如果需要地址栏的地址发生改变,就选择重定向;如果需要在Servlet之间通过request域进行数据通信,就选择请求转发相同之处:两者都可以进行多次请求转发。
四.Struts 2作为一种Java Web框架,其主要作用是什么,在哪些方面比Servlet/JSP开发提高了开发效率,详细论述。
答:Struts:它通过采用Java Servlet/JSP 技术,实现了基于Java EEWeb应用的MVC设计模式的应用框架,是MVC经典设计模式中的一个经典产品。
Struts 2以WebWork为核心,采用拦截器的机制来处理用户的请求,这样的设计也使得业务逻辑控制器能够与Servlet API完全脱离开Struts 是MVC的一种实现,它将Servlet和JSP 标记(属于J2EE 规范)用作实现的一部分。
Struts继承了MVC的各项特性,并根据J2EE的特点,做了相应的变化与扩展,减弱了业务逻辑接口和数据接口之间的耦合,以及让视图层更富于变化。
另外, struts具有页面导航功能,使系统的脉络更加清晰。
通过一个配置文件,即可把握整个系统各部分之间的联系,这对于后期的维护有着莫大的好处。
struts2的特点之一就是它替代servlet的操作类就是一个典型的javabean,首先struts2框架将页面传输的数据进行类型转化和封装后将请求信息封装到了这个javabean的属性里,这样我们开发web程序时候就省去了烦心的类型转化和封装的问题Servlet另一个作用就是构造response对象,让页面获得正确的响应,其实现代的浏览器是一个多媒体工具,文字,图片,视屏等等东西都可以在浏览器里显示,资源的不同就会导致http响应报文的差别,如果我们使用servlet开发就要根据资源的不同在java程序里用硬编码的形式处理,这样的程序很难复用,而且如果程序员对某种资源的处理理解不到位,就会导致问题的出现,struts2通过配置文件的形式将这样的逻辑从java程序里剥离出来,使用配置的方式进行统一管理,这个做法和spring的AOP方式类似,这样就让结果处理方式更加统一,更加利于管理,同时也提升了程序的健壮性以及降低了开发的难度Servlet里还有两个重要的技术:监听器和过滤器,对于监听器在web开发里使用的场景比较少,都是一些十分特别的情况才会使用,大部分web开发里可以忽略它的使用,我们用的最多的监听器可能就是对ServletContext创建和销毁的监听器,ServletContext是整个web应用的全局对象,它和Web应用的生命周期绑定在一起,因此使用这个监听器对Web应用的全局信息进行初始化和销毁操作,例如spring容器的初始化操作。
比较有意思的是过滤器,在struts2里有个拦截器,它们的作用相同都是用来拦截请求的,因为拦截器是struts2的特有功能,在struts2里使用拦截器自然比使用过滤器更顺手,其实拦截器所用的技术比过滤器更加先进,因为拦截器使用了反射技术,因此拦截器拦截的面更大,控制请求的能力更强,它能完成的任务也会更加的丰富多彩五.Java Web开发中为什么要采用一些ORM框架,何为ORM框架,其主要代表框架Hibernate简化了哪些方面的开发,详细论述。
答:原因:只要提供了持久化类与表的映射关系,ORM框架在运行时就能参照映射文件的信息,把对象持久化到数据库中ORM框架:ORM框架采用元数据来描述对象一关系映射细节,元数据一般采用XML格式,并且存放在专门的对象一映射文件中。
Hibernate是一个持久化框架和ORM框架,持久化和ORM是两个有区别的概念,持久化注重对象的存储方法是否随着程序的退出而消亡,ORM关注的是如何在数据库表和内存对象之间建立关联。
Hibernate使用POJO来表示Model,使用XML配置文件来配置对象和表之间的关系,它提供了一系列API来通过对对象的操作而改变数据库中的过程。
Hibernate更强调如何对单条记录进行操作,对于更复杂的操作,它提供了一种新的面向对象的查询语言:HQL。
六.Spring框架的IoC是指什么,AOP是指什么,在Java Web开发中有哪些实际应用,试简要描述。