j2ee考试题1

来源:互联网 发布:射手影音 for mac 编辑:程序博客网 时间:2024/05/17 06:46

在JSP中,使用<jsp:useBean>动作可以将javaBean嵌入JSP页面,对JavaBean的访问范围不能是()。
a) page               b) request
c) response        d) application.C2...WEB应用中,常用的会话跟踪方法不包括()。
a) URL重写           b) Cookie
c) 隐藏表单域        d) 有状态HTTP协议.D2...在J2EE中,${2 + “4”}将输出()。
a)  2 + 4          b) 6
c)  24               d) 不会输出,因为表达式是错误的 .B2...在J2EE的ModelⅡ模式中,模型层对象被编写为( )。
a)  Applet           b) JSP
c)  Server           d) JavaBean.D2...给定JSP程序源码如下:
<html>
<% int count =1;%> _______
</html>
以下()语句可以在下划线处插入,并且运行后输出结果是:1。
 a)  <%=++count %>           b) <% ++count; %>
 c)  <% count++; %>          d) <% =count++ %>.D2...servlet 的生命周期又一系列事件组成,把这些事件按照先后顺序排序,以下正确的是()
a)  加载类,实例化,请求处理,初始化,销毁
b)  加载类,实例化,初始化,请求处理,销毁
c)  实例化,加载类,初始化,请求处理,销毁
d)  加载类,初始化,实例化,请求处理,销毁.B2...某web应用的上下文路径是root,配置文件web.xml中有如下片段:
<servlet>
 <servlet-name>process</servlet-name>
 <servlet-class>slt.ProcessServlet</servlet-class>
</servlet>
<servlet-mapping>
 <servlet-name>process</servlet-name>
 <url-pattern>/proc</url-pattern>
</servlet-mapping>
以下说法正确的是(  )。
A) 在包slt中,有一个名为ProcessServletroot.class的文件
B) 该servlet的访问路径是http://机器IP:端口号/root/proc
C) 该servlet的访问路径是http://机器IP:端口号/root/ProcessServlet
D) 该servlet的访问路径是http://机器IP:端口号/root/ProcessServlet.B2...在J2EE中,test.jsp文件中有如下一行代码:
<jsp:useBean id=”user” scope=”__” type=”com.UserBean”>
要使user对象可以作用于整个应用程序,下划线中应添入()。
a)  page          b)  request
c)  session       d)  application.D2...在J2EE中,<%=2+4%>将输出()。
   a) 2+4
   b) 6
   c) 24
   d) 不会输出,因为表达式是错误的.B2...在J2EE中,request对象的()方法可以获取页面请求中一个表单组件对应多个值时的用户的请求数据。
   a) String  getParameter(String name)
   b) String[] getParameter(String name)
   c) String  getParameterValues(String name)
   d) String[] getParameterValues(String name).D2...在J2EE中,使用Servlet过滤器时,需要在web.xml通过()元素将过滤器映射到Web资源。
   a) <filter>
   b) <filter-mapping>
   c) <servlet>
   d) <servlet-mapping>.B2...Web应用中,常用的会话跟踪方法不包括()。
   a) URL重写
   b) Cookie
   c) 隐藏表单域
   d) 有状态HTTP协议.D2...下面哪一个不是JSP本身已加载的基本类?()
A、java.lang.*   
B、java.io.* 
C、javax.servlet.* 
D、javax.servlet.jsp.*.B2...对于预定义<%!预定义%>的说法错误的是:()
A、一次可声明多个变量和方法,只要以“;”结尾就行  
B、一个声明仅在一个页面中有效
C、声明的变量将作为局部变量        
D、在预定义中声明的变量将在JSP页面初始化时初始化.C2...从 “员工” 表的“姓名”字段中找出名字包含“玛丽”的人,下面哪条select语句正确:()
A、 Select * from员工 where 姓名 =’_玛丽_’ 
B 、Select * from员工 where 姓名 =’%玛丽_’
C、 Select * from员工 where 姓名 like ‘_玛丽%’ 
D、 Select * from员工 where 姓名 like ‘%玛丽%’.D2...Given the JSP code:
<% request.setAttribute("foo", "bar"); %>
and the Classic tag handler code:
5. public int doStartTag() throws JspException {
6. // insert code here
7. // return int
8. }
Assume there are no other "foo" attributes in the web application.
Which invocation on the pageContext object, inserted at line 6, assigns "bar" to the variable x?
A. String x = (String)pageContext.getAttribute("foo");
B. String x = (String)pageContext.getRequestScope("foo");
C. It is NOT possible to access the pageContext object from within doStartTag.
D. String x = (String)pageContext.getRequest().getAttribute("foo");.D2...Servlet A receives a request that it forwards to servlet B within another web application in the
same web container. Servlet A needs to share data with servlet B and that data must not be
visible to other servlets in A's web application. In which object can the data that A shares with B
be stored?
A. HttpSession
B. ServletConfig
C. ServletContext
D. HttpServletRequest.D2...Which JSTL code snippet can be used to perform URL rewriting?
A. <a href='<c:url url="foo.jsp"/>' />
B. <a href='<c:link url="foo.jsp"/>' />
C. <a href='<c:url value="foo.jsp"/>' />
D. <a href='<c:link value="foo.jsp"/>' />.C2...A developer has used this code within a servlet:
62. if(request.isUserInRole("vip")) {
63. // VIP-related logic here
64. }
What else must the developer do to ensure that the intended security goal is achieved?
A. Create a user called vip in the security realm
B. Define a group within the security realm and call it vip
C. Define a security-role named vip in the deployment descriptor
D. Declare a security-role-ref for vip in the deployment descriptor.D2...Given this fragment in a servlet:
23. if(req.isUserInRole("Admin")) {
24. // do stuff
25. }
And the following fragment from the related Java EE deployment descriptor:
 <security-role-ref>
 <role-name>Admin</role-name>
 <role-link>Administrator</role-link>
 </security-role-ref>
 <security-role>
 <role-name>Admin</role-name>
 <role-name>Administrator</role-name>
 </security-role>
What is the result?
A. Line 24 can never be reached.
B. The deployment descriptor is NOT valid.
C. If line 24 executes, the user's role will be Admin.
D. If line 24 executes, the user's role will be Administrator..D2
"Which three are true about the HttpServletRequestWrapper class? (Choose two.)
A. The HttpServletRequestWrapper is an example of the Decorator pattern.
B. The HttpServletRequestWrapper can be used to extend the functionality of a servlet request.
C. A subclass of HttpServletRequestWrapper CANNOT modify the behavior of the getReader
method.
D. An HttpServletRequestWrapper may be used only by a class implementing the
javax.servlet.Filter interface." . A,B
.
.
.
"You need to store a Java long primitive attribute, called customerOID, into the session scope.
Which two code snippets allow you to insert this value into the session? (Choose two.)
A. long customerOID = 47L;
session.setAttribute(""customerOID"", new Long(customerOID));
B. long customerOID = 47L;
session.setLongAttribute(""customerOID"", new Long(customerOID));
C. long customerOID = 47L;
session.setAttribute(""customerOID"", customerOID);
D. long customerOID = 47L;
session.setNumericAttribute(""customerOID"", new Long(customerOID));" . A,C
.
.
.
"Assume the scoped attribute priority does NOT yet exist. Which two create and set a new
request-scoped attribute priority to the value ""medium""? (Choose two.)
A. ${priority = 'medium'}
B. ${requestScope['priority'] = 'medium'}
C. <c:set var=""priority"" value=""medium"" scope=""request"" />
D. <c:set var=""priority"" scope=""request"">medium</c:set>
" . C,D
.
.
.
"Question: 33
Which two JSTL URL-related tags perform URL rewriting? (Choose two.)
A. Url
B. Redirect
C. Param
D. Import" . A,B
.
.
.
"A custom JSP tag must be able to support an arbitrary number of attributes whose names are
unknown when the tag class is designed. Which two are true? (Choose two.)
A. The <body-content> element in the echo tag TLD must have the value JSP.
B. The echo tag handler must define the setAttribute(String key, String value) method.
C. The <dynamic-attributes>true</dynamic-attributes> element must appear in the echo tag TLD.
D. The class implementing the echo tag handler must implement the" . C,D
.
.
.
"If you want to use the Java EE platform's built-in type of authentication that uses a custom HTML
page for authentication, which two statements are true? (Choose two.)
A. Your deployment descriptor will need to contain this tag: <auth-method>CUSTOM</authmethod>.
B. The related custom HTML login page must be named loginPage.html.
C. In the HTML related to authentication for this application, you must use predefined variable names for the variables that store the user and password values.
D. You must have a tag in your deployment descriptor that allows you to point to both a login HTML page and an HTML page for handling any login errors." . C,D
.
.
.
"Which three are valid URL mappings to a servlet in a web deployment descriptor? (Choose
three.)
A. */*
B. *.do
C. /MyServlet/*
D. /MyServlet" . B,C,D

Servlet的生命周期分三个时期:装载Servlet 、创建一个Servlet实例、销毁。 A
服务器启动后就产生了这个application对象,当客户在所访问的网站的各个页面之间浏览时,这个application对象都是同一个,直到服务器关闭。 A
J2EE容器包括的服务器端容器有Wed容器,EJB容器,Application Client容器。 B
Servlet程序的入口点是main() B
JDBC的主要任务是:与数据库建立连接、发送SQL语句、处理结果。 A
一个Bean由三部分组成:实现java.io.serializable接口、提供无参数的构造方法、提供get()和set()方法访问它的属性。 B
理论上,GET是 用于获取服务器信息并将其作为响应返回给客户端,POST是用于客户端把数据传送到服务器 。 A
jsp主要内置对象有: application、pageexception、pageContext、request、session、response、out、config、page。 B
组件是JavaEE应用的基本单元。JavaEE提供的组件主要包括三类:客服端组件、Web组件和EJB组件。 A
MVC设计模式的核心组成有模型、视图、控制器。 A

原创粉丝点击