1.B 编写一个Filter,需要() A. 继承Filter 类 B. 实现Filter 接口 C. 继承HttpFilter 类 D. 实现HttpFilter接口 2.D 自定义标签的配置文件放在________ A. WebRoot B. lib C. classes D. WEB-INF 3. ABC 有关会话跟踪技术描述正确的是( )(多选) A. Cookie是Web服务器发送给客户端的一小段信息,客户端请求时,可以读取该信息发送到服务器端。 B. 关闭浏览器意味着会话ID丢失,但所有与原会话关联的会话数据仍保留在服务器上,直至会话过期。 C. 在禁用Cookie时可以使用URL重写技术跟踪会话。 D. 隐藏表单域将字段添加到HTML表单并在客户端浏览器中显示。 4.C 在J2EE中,重定向到另一个页面,以下()语句是正确的 A. request . sendRedirect(“http :// www . svse . com . cn”); B. request . sendRedirect(); C. response . sendRedirect(“http: // www . svse . com . cn”); D. response .sendRedirect(); 5.B EL表达式,${10 mod 3},执行结果为( ) A. 10 mod 3 B. 1 C. 3 D. null 6. C 自定义标签的作用是( ) A. 编写和使用方便 B. 规定是这样的,如果不用,别人会说我们不专业 C. 可以减少jsp中的java代码,将代码与界面标签分离,简化前台开发 D. 连数据库 7.B request.getRequestDispatcher().forward(request,response)称之为( ) A. 流转 B. 转发 C. 重定向 D. 导航 8. BCD 有关Servlet的生命周期说法正确的有( ) (多选) A. Servlet的生命周期由Servlet实例控制。 B. init()方法在创建完Servlet实例后对其进行初始化,传递的参数为实现ServletContext 接口的对象。 C. service()方法响应客户端发出的请求。 D. destroy()方法释放Servlet实例。 9.B 在J2EE中,给定某Servlet的代码如下,编译运行该文件,以下陈述正确的是()。(选择一项) Public class Servlet1 extends HttpServlet{ public void init() throws ServletException{ } public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); out.println("hello!"); } A. 编译该文件时会提示缺少doGet()或者dopost()方法,编译不能够成功通过 B. 编译后,把Servlet1.class放在正确位置,运行该Servlet,在浏览器中会看到输出文字:hello!
An Overview of Servlet and JSP Technology Nagle ,Wiegley Abstract: Servlet program running in the server-side, dynamically generated Web page with the traditional CGI and many other similar compared to CGI technology, Java Servlet with a more efficient, easier to use, more powerful and has better portability, more savings to invest. . Keywords: JSP Technology;Servlet;HTTP server 1. A Servlet's Job Servlets are Java programs that run on Web or application servers, acting as a middle layer between requests coming from Web browsers or other HTTP clients and databases or applications on the HTTP server. Their job is to perform the following tasks, as illustrated in Figure 1-1. Figure 1-1Web middleware role 1.1 Read the explicit data sent by the client. The end user normally enters this data in an HTML form on a Web page. However, the data could also come from an applet or a custom HTTP client program. 1.2 Read the implicit HTTP request data sent by the browser. Figure 1-1 shows a single arrow going from the client to the Web server (the layer where servlets and JSP execute), but there are really two varieties of data: the explicit data that the end user enters in a form and the behind-the-scenes HTTP information. Both varieties are critical. The HTTP information includes cookies, information about media types and compression schemes the browser understands, and so on. 1.3 Generate the results. This process may require talking to a database, executing an RMI or EJB call, invoking a Web service, or computing the response directly. Your real data may be in a relational database. Fine. But your database probably doesn't speak HTTP or return results in HTML, so the Web browser can't talk directly to the database. Even if it could, for security reasons, you probably would not want it to. The same argument applies to most other applications.You need the Web middle layer to extract the results inside a document.
Web应用开发(Java高级软件开发)工程师培训班 JSP和Servlet考试试卷 姓名:分数: 第一部分:笔试部分。 二、简答题(共5题,每题8分,共40分) 1、JSP有哪些内置对象?作用分别是什么? 2、Servlet在什么情况下调用doGet()?什么情况下调用doPost()? 3、简述PreparedStatement和Statement的区别与联系? 4、在Jcbc编程时为什么要养成经常释放连接的习惯? 5、Connection、PreparedStatement、Statement、CallableStatement、ResultSet是JDBC 编程常用的接口,请分别简述它们的作用? 第二部分:上机部分。(共60分) 1、使用JSP+Servlet+数据库的方式完成一个简易的库存商品管理系统,请自己设计数据库(1)、需求描述: ①、管理员登录 ②、列出所有库存商品的名称、规格、库存件数、单价 ③、可以对库存记录做增加、修改和删除。 (2)、页面功能设计参考
点“新加商品”按钮,跳到下页进行新加商品 删除前需要用户确认 在每行的修改链接中,链接到本行记录的修改页面 说明: 商品增加(修改)成功后,页面回到管理员查看库存页,并刷新列表数据; 所有字段均为必填项,件数、单价为数字项,提交数据之前,应进行充分的检查; 保存记录的时候,程序检测如果该件商品已有记录(即:名称、规格、单价都相同的商品),则在原有库存上累加,否则新加记录;
第一部分:笔试部分 一、简答题 1、JSP有哪些内置对象?作用分别是什么? jsp9个常用的内置对象如下 request对象:客户端的请求信息被封装在request对象中,通过它才能了解到客户的需求,然后做出响应。它是HttpServletRequest类的实例。 response对象:response对象包含了响应客户请求的有关信息,但在JSP中很少直接用到它。它是HttpServletResponse类的实例。 session对象:session对象指的是客户端与服务器的一次会话,从客户连到服务器的一个WebApplication开始,直到客户端与服务器断开连接为止。它是HttpSession 类的实例。 out对象:out对象是JspWriter类的实例,是向客户端输出内容常用的对象 page对象:page对象就是指向当前JSP页面本身,有点象类中的this指针,它是https://www.doczj.com/doc/cc14693563.html,ng.Object类的实例。 application对象:application对象实现了用户间数据的共享,可存放全局变量。 它开始于服务器的启动,直到服务器的关闭,在此期间,此对象将一直存在;这样 在用户的前后连接或不同用户之间的连接中,可以对此对象的同一属性进行操作; 在任何地方对此对象属性的操作,都将影响到其他用户对此的访问。服务器的启动 和关闭决定了application对象的生命。它是ServletContext类的实例。 exception对象:exception对象是一个例外对象,当一个页面在运行过程中发生了例外,就产生这个对象。如果一个JSP页面要应用此对象,就必须把isErrorPage 设为true,否则无法编译。他实际上是https://www.doczj.com/doc/cc14693563.html,ng.Throwable的对象。 pageContext对象:pageContext对象提供了对JSP页面内所有的对象及名字空间的
jsp+servlet实例 开发环境myeclipse+tomcat6 1、先创建web project,项目名为RegisterSystem, 2、在WebRoot 目录下创建login.jsp文件,只需修改body中的内容,如下所示:
3、在scr目录下的com.ht.servlet编写AcountBean.java文件,代码如下:package com.ht.servlet; public class AccountBean { private String username = ""; private String password = ""; public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getUsername() { return username; } public void setUsername(String username) { https://www.doczj.com/doc/cc14693563.html,ername = username; } } 4、在scr目录下的com.ht.servlet编写servlet类CheckAccount.java文件,代码如下: package com.ht.servlet; import java.io.IOException;这几天做了一个项目,大量用到了JSP与servlet之间的传值,总结了一下 JSP与servlet之间的传值有两种情况:JSP -> servlet, servlet -> JSP. 通过对象request和session (不考虑application)完成传值. 一、JSP -> servlet JSP页面有3种方法向servlet传值:form表单、URL 、其他 ... <%...... session.setAttribute("testSession","Hello session"); reqeust.setAttribute("testRequest","Hello request"); %> click me
... 1、对于该JSP页面form表单的内容,如标签,在servlet可用request.getParameter("username");获取. 2、URL:比如这里的标签的href属性与