JSP复习题1Word下载.docx

上传人:b****2 文档编号:877048 上传时间:2023-04-29 格式:DOCX 页数:15 大小:21.50KB
下载 相关 举报
JSP复习题1Word下载.docx_第1页
第1页 / 共15页
JSP复习题1Word下载.docx_第2页
第2页 / 共15页
JSP复习题1Word下载.docx_第3页
第3页 / 共15页
JSP复习题1Word下载.docx_第4页
第4页 / 共15页
JSP复习题1Word下载.docx_第5页
第5页 / 共15页
JSP复习题1Word下载.docx_第6页
第6页 / 共15页
JSP复习题1Word下载.docx_第7页
第7页 / 共15页
JSP复习题1Word下载.docx_第8页
第8页 / 共15页
JSP复习题1Word下载.docx_第9页
第9页 / 共15页
JSP复习题1Word下载.docx_第10页
第10页 / 共15页
JSP复习题1Word下载.docx_第11页
第11页 / 共15页
JSP复习题1Word下载.docx_第12页
第12页 / 共15页
JSP复习题1Word下载.docx_第13页
第13页 / 共15页
JSP复习题1Word下载.docx_第14页
第14页 / 共15页
JSP复习题1Word下载.docx_第15页
第15页 / 共15页
亲,该文档总共15页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

JSP复习题1Word下载.docx

《JSP复习题1Word下载.docx》由会员分享,可在线阅读,更多相关《JSP复习题1Word下载.docx(15页珍藏版)》请在冰点文库上搜索。

JSP复习题1Word下载.docx

contextc) 

out

6)Servlet中,HttpServletResponse的()方法用来把一个Http请求重定向到另外的URL。

sendURL() 

b)redirectURL()c) 

sendRedirect() 

d)redirectResponse()

7)在JSP中,page指令的()属性用来引入需要的包或类。

extendsb)importc)languged)contentType

8)在Servlet过滤器的生命周期方法中,每当传递请求或响应时,web容器会调用()方法。

init 

b) 

servicec) 

doFilter 

destroy

9)在JSP中,只有一行代码:

%=’A’+’B’%>

,运行将输出()。

A+Bb) 

ABc) 

131 

错误信息,因为表达式是错误的

10)给定一个Servlet的代码片段如下:

PublicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)

throwsServletException,IOException{ 

______

out.println(“hikitty!

”);

out.close();

}

运行次Servlet时输出如下:

hikitty!

则应在此Servlet下划线处填充如下代码。

(选项一项)

PrintWriterout=response.getWriter();

PrintWriterout=request.getWriter();

c) 

OutputStreamout=response.getOutputStream();

OutputStreamout=request.getWriter();

11)给定如下JSP代码,假定在浏览器中输入URL:

http:

//localhost:

8080/web/jsp1.jsp,可以调用这个JSP,那么这个JSP的输出是()。

%@pagecontentType="

text/html;

charset=GBK"

%@tagliburi=” 

prefix=”c”%>

html>

body>

%intcounter=10;

c:

iftest=”${counter%2==1}”>

setvar=”isOdd”value=”true”>

/c:

set>

if>

choose>

whentest=”${isOdd==true}”>

it’sanodd<

when>

otherwise>

it’saneven<

/body>

/html>

一个HTML页面,页面上显示it’sanoddb) 

一个HTML页面,页面上显示it’sanevenc) 

一个空白的HTML页面d) 

错误信息

12)给定java程序User.java,代码如下:

packageuser;

publicclassUser{

privateStringpassword;

privateStringloginName;

publicStringgetLoginName(){

returnloginName;

}

publicStringgetPassword(){

returnpassword;

publicvoidsetLoginName(StringloginName){

this.loginName=loginName;

publicvoidsetPassword(Stringpassword){

this.password=password;

给定user.jsp,代码片断如下:

____________

loginName:

<

getPropertyname=”user”property=”loginName”/>

password:

getPropertyname=”user”property=”password”/>

在浏览器上输入URL:

//localhost/user,jsp?

loginName=sa&

password=sa并回车

要使浏览器上显示:

sa 

password:

sa

在user.jsp中的下划线处应填入以下()代码. 

(选择一项)

useBeanid=”user”class=”user.User”scope=”page”/>

setPropertyname=”user”property=”loginName”value=”*”/>

setPropertyname=”user”property=”password”value=”*”/>

useBeanid=”user”class=”user.User”scope=”application”/>

c) 

useBeanid=”user”class=”user.User”scope=”application”/>

setPropertyname=”user”property=”*”/>

useBeanid=”user”class=”user.User”scope=”page”/>

13) 

某JSP程序中声明使用javaBean的语句如下:

useBeanid=”user”class=”mypackage.User”scope=”pge”/>

要取出该javaBean的loginName属性值,以下语句正确的是(). 

(选择两项)

getPropertyname=”user”property=”loginName’/>

getPropertyid=”user’property=”loginName”/>

%=user.getLoginName()%>

%=user.getProperty(“loginName”)%>

14)J2EE中,以下关于HttpServlet的说法错误的是()。

a) 

HttpServlet是一个抽象类

HttpServlet类扩展了GenericServlet类

c) 

HttpServlet类的子类必须至少重写service方法

HttpServlet位于javax.servlet.http包中

15)给顶一个JSP程序源代码,如下:

includepage="

two.jsp"

flush="

true"

>

paramname="

location"

value="

bejing"

/>

/jsp:

include>

在two.jsp中使用()代码片段可以输出参数location的值。

getParamname="

getParametername="

%=request.getAttribute("

)%>

%=request.getParameter("

16)J2EE中,JSPEL表达式:

s{(10*10)ne100}的值是()。

Truec) 

False 

1

17)在J2EE中,test.jsp文件如下:

%{%>

useBean 

id="

buffer"

scope="

page"

type="

java.lang.StringBuffer"

buffer.append("

ABC"

);

%>

%}%>

buffer 

is 

%=buffer%>

运行时,将发生()。

转译期错误 

运行期错误c) 

运行后,浏览器上显示:

bufferisnull

bufferisABC

18) 

如JSP页面执行时遇到自定义标签,doStartTag()方法将被调用()次。

1或多c) 

0或1 

0或多

19) 

给定include1.jsp文件代码片断,如下:

%pageContext.setAttribute("

User"

"

HAHA"

_______//此处填写代码

给定include2.jsp文件代码片断,如下:

%=pageContext.getAttribute("

要求运行include1.jsp时,浏览器上输出:

HAHA

要满足以上条件,jsp1.jsp中下划线处应填入以下()语句。

include2.jsp"

 

%@includefile="

forwordpage="

%response.sendRedirect("

20)在J2EE中,在web.xml中,有如下代码:

session-config>

session-timeout>

30<

/session-timeout>

/session-config>

上述代码定义了默认的会话超时时长,时长为30( 

)。

毫秒 

b)秒

分钟 

d)小时

21) 

在inc.jsp中包含数行代码与一张图片,现在要创建一个home.jsp,每次浏览home.jsp时都能够以最快的速度显示inc.jsp中的所有内容以及home.jsp自身要显示的内容,应该在home.jsp中使用的语句是( 

a)<

%@includefile=“inc.jsp”%>

%@includepage=“inc.jsp”flush=“true”>

c)<

includefile=“inc.jsp”flush=“false”>

d)<

forwardpage=“inc.jsp”/>

22) 

给定一个JSP程序源码如下:

includepage=“two.jsp”flush=“true”>

paramname=“location”value=“beijing”/>

在two.jsp中加入( 

)代码片断可以输出参数location的值。

getParamname=“location”>

b)<

getParametername=“location”>

%=request.getAttribute(“location”)%>

d)<

%=request.getParameter(“location”)%>

23)使用自定义标签时,要为JSP引擎提供有关自定义标签的相关信息,下列信息描述语句正确的是( 

)。

tag>

name>

hello<

/name>

tag-class>

com.tagdemo.HelloTag<

/tag-class>

/tag>

b)<

taglib>

/taglib>

c)<

tag-info>

tagclass>

/tagclass>

/tag-info>

d)<

tag-desc>

/tag-desc>

24)要设置某个JSP页面为错误处理页面,以下page指令正确的是()。

%@pageerrorPage="

%@pageisErrorPage="

%@pageextends="

javax.servlet.jsp.JspErrorPage"

d) 

%@pageinfo="

error"

25)JavaMail是一组用于发送和接收邮件消息的API。

发送邮件使用()协议,接收邮件使用()协议。

a)POP3 

SMTPb)POP3 

TCPc)SMTP 

TCP 

d)SMTP 

POP3

26)在Servlet里,能正确获取session的语句是()。

a) 

HttpSessionsession=request.getSession(true);

HttpSessionsession=request.getHttpSession(true);

HttpSessionsession=response.getSession(true);

HttpSessionsession=response.getHttpSession(true);

27)在JSP中,()动作用于将请求转发给其他JSP页面。

a)forward 

b)includec)useBean 

d)setProperty

28)在J2EE中,在一个JSP文件中,有表达式<

%=2+3%>

,它将输出()。

a)2+3 

b)5 

23 

不会输出,因为表达式是错误的

29)在J2EE实现企业级应用开发中,()是描述标记库的XML文档。

TLD文件b)DTD文件c)WAR文件d) 

EAR文件

30)给定JSP程序源码如下,可以在下划线处插入并且能够正确输出WELCOME,JACK的语句是()。

(选择二项)

Stringname="

JACK"

;

WELCOME,______

a)name 

%=name%>

c)out.println(name);

d)<

%out.println(name);

31)在J2EE中,重定向到另一个页面,以下()语句是正确的。

request.sendRedirect("

//www.jb-"

request.sendRedirect();

response.sendRedirect("

response.sendRedirect();

32)在JSP中,使用<

useBean>

动作可以将javaBean嵌入JSP页面,对JavaBean的访问范围不能是()。

a)page 

b)requestc)response 

d)application

33)在J2EE中,使用Servlet过滤器时,可以在web.xml文件的()元素中包括<

init-param>

元素。

filter>

b)<

filter-mapping>

filter-name>

filter-class>

34)Servlet中,使用()接口中定义的()方法来处理客户端发出的表单数据请求(选一项)

HttpServlet 

doHead 

doPost

ServletRequest 

doGet 

35)给定JSP程序源码如下,该JSP运行后输出的结果是()。

%intcount=1;

Count:

%++count;

a)Count:

b)Count:

2c)1:

d)Count:

36)给定如下Servlet代码,假定在浏览器中输入URL:

8080/servlet/HelloServlet,可以调用这个servlet,那么这个Servlet的输出是()。

importjava.io.*;

importjavax.servlet.*;

importjavax.servlet.http.*;

publicclassHelloServletextendsHttpServlet{

publicvoidservice(HttpServletRequestreq,HttpServletResponseres)

throwsServletException,IOException{

publicvoiddoGet(HttpServletRequestreq,HttpServletResponseres)

throwsServletException,IOException{

res.setContentType("

text/html"

PrintWriterout=res.getWriter();

out.println("

"

doGetHelloWorld!

out.close();

publicvoiddoPost(HttpServletRequestreq,HttpServletResponseres)

doPostHelloWorld!

a)一个HTML页面,页面上显示doGetHelloWorld!

b)一个HTML页面,页面上显示doPostHelloWorld!

c)一个空白的HTML页面

d)错误信息

37)在J2EE中,request对象的( 

)方法可以获取页面请求中一个表单组件对应多个值时的用户的请求数据。

StringgetParameter(Stringname)

String[]getParameter(Stringname)

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 法律文书 > 调解书

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2