站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Java 专题一套JSP测试题

一套JSP测试题

摘要: 一套JSP测试题

</td> </tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="418" height="86" align="left" valign="top">


(1)假设在helloapp应用中有一个hello.jsp,它的文件路径如下:
%CATALINA_HOME%/webapps/helloapp/hello/hello.jsp
那么在浏览器端访问hello.jsp的URL是什么? (单选)
选项:
(A) http://localhost:8080/hello.jsp
(B) http://localhost:8080/helloapp/hello.jsp
(C) http://localhost:8080/helloapp/hello/hello.jsp

(2)假设在helloapp应用中有一个HelloServlet类,它位于org.javathinker包下,那么这个类的class文件应该放

在什么目录下? (单选)
选项:
(A) helloapp/HelloServlet.class
(B) helloapp/WEB-INF/HelloServlet.class
(C) helloapp/WEB-INF/classes/HelloServlet.class
(D) helloapp/WEB-INF/classes/org/javathinker/HelloServlet.class

</td> <td width="266" valign="top"> </td> </tr> </table>

(3)假设在helloapp应用中有一个HelloServlet类,它在web.xml文件中的配置如下:

HelloServlet
org.javathinker.HelloServlet



HelloServlet
/hello

那么在浏览器端访问HelloServlet的URL是什么? (单选)
选项:
(A) http://localhost:8080/HelloServlet
(B) http://localhost:8080/helloapp/HelloServlet
(C) http://localhost:8080/helloapp/org/javathinker/hello
(D) http://localhost:8080/helloapp/hello


(4)客户请求访问HTML页面与访问Servlet有什么异同?(多选)
选项:
(A)相同:都使用HTTP协议
(B)区别:前者Web服务器直接返回HTML页面,后者Web服务器调用Servlet的方法,由Servlet动态生成HTML页面
(C)相同:前者Web服务器直接返回HTML页面,后者Web服务器直接返回Servlet的源代码。
(D)区别:后者需要在web.xml中配置URL路径。
(E)区别:前者使用HTTP协议,后者使用RMI协议。


(5)HttpServletRequest对象是由谁创建的?(单选)
选项:
(A)由Servlet容器负责创建,对于每个HTTP请求, Servlet容器都会创建一个HttpServletRequest对象
(B)由JavaWeb应用的Servlet或JSP组件负责创建,当Servlet或JSP组件响应HTTP请求时,先创建

HttpServletRequest对象


(6)从HTTP请求中,获得请求参数,应该调用哪个方法? (单选)
选项:
(A)调用HttpServletRequest对象的getAttribute()方法
(B)调用ServletContext对象的getAttribute()方法
(C)调用HttpServletRequest对象的getParameter()方法

(7)ServletContext对象是由谁创建的?(单选)
选项:
(A)由Servlet容器负责创建,对于每个HTTP请求, Servlet容器都会创建一个ServletContext对象
(B)由JavaWeb应用本身负责为自己创建一个ServletContext对象
(C)由Servlet容器负责创建,对于每个JavaWeb应用,在启动时,Servlet容器都会创建一个ServletContext对象


(8)jspForward1.jsp要把请求转发给jspForward2.jsp,应该在jspForward1.jsp中如何实现? (单选)
选项:
(A) jspForward2.jsp
(B)

(9)当浏览器第二次访问以下JSP网页时的输出结果是什么?(单选)

<%
int b=0;
a++;
b++;
%>

a:<%= a %>

b:<%= b %>

选项:
(A) a=0 b=0
(B) a=1 b=1
(c) a=2 b=1

(10)下面哪个说法是正确的? (单选)
选项:
(A) 对于每个要求访问maillogin.jsp的HTTP请求,Servlet容器都会创建一个HttpSession对象
(B)每个HttpSession对象都有惟一的ID。
(C)JavaWeb应用程序必须负责为HttpSession分配惟一的ID

(11)如果不希望JSP网页支持Session,应该如何办? (单选)
选项:
(A) 调用HttpSession的invalidate()方法
(B) <%@ page session= “false\">


(12)在标签处理类中,如何访问session范围内的共享数据? (多选)
选项:
(A)在TagSupport类中定义了session成员变量,直接调用它的getAttribute()方法即可。
(B)在标签处理类TagSupport类中定义了pageContext成员变量,先通过它的getSession()方法获得当前的

HttpSession对象,再调用HttpSession对象的getAttribute()方法。
(C)pageContext.getAttribute(“attributename”,PageContext.SESSION_SCOPE)


(13)在下面的选项中,哪些是TagSupport类的doStartTag()方法的有效返回值? (多选)
选项:
(A) Tag.SKIP_BODY
(B) Tag.SKIY_PAGE
(C) Tag.EVAL_BODY_INCLUDE
(D) Tag.EVAL_PAGE


(14)以下代码能否编译通过,假如能编译通过,运行时得到什么打印结果?(单选)
request.setAttribute(\"count\",new Integer(0));
Integer count = request.getAttribute(\"count\");
选项:
A)不能编译通过 B)能编译通过,并正常运行
C) 编译通过,但运行时抛出ClassCastException

点击观看答案

</td> </tr> <tr>


↑返回目录
前一篇: 在JSP中使用简繁体网页
后一篇: 多用户网站统计系统