1)在JSP中,要定義一個方法,需要用到以下()元素。(選擇一項)
a) <%= %> b) <% %>
c) <%! %> d) <%@ %>
2)JSP頁面經過編譯之后,將創建一個()。(選擇一項)
a) applet b) servlet
c) application d) exe文件
3)當JSP頁面執行自定義標簽,遇到結束標簽時將調用()方法執行處理。(選擇一項)
a) doStartTag() b) doEndTag()
c) doInitBody() d) doAfterBody()
4) 在J2EE中,test.jsp文件中有如下一行代碼:(選擇一項)
<jsp:useBean id=”user” scope=”_____” type=”com.UserBean”/>
要使user對象中一直存在於對話中,直至其終止或被刪除為止,下划線中應填入()。
a) page b) request
c) session d) application
5) 在J2EE中,以下不是JSP隱式對象的是()。(選擇一項)
a) pageContext b) context
c) application d) out
6) Servlet中,HttpServletResponse的()方法用來把一個Http請求重定向到另外的URL。(選擇一項)
a) sendURL() b) redirectURL()
c) sendRedirect() d) redirectResponse()
7) 在JSP中,page指令的()屬性用來引入需要的包或類。(選擇一項)
a) extends b) import
c) languge d) contentType
8) 在Servlet過濾器的生命周期方法中,每當傳遞請求或響應時,web容器會調用()方法。(選擇一項)
a) init b) service
c) doFilter d) destroy
9) 在JSP中,只有一行代碼:<%=’A’+’B’%>,運行將輸出()。(選擇一項)
a) A+B b) AB
c) 131 d) 錯誤信息,因為表達式是錯誤的
10)給定一個Servlet的代碼片段如下:
Public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException{
______
out.println(“hi kitty!”);
out.close();
}
運行次Servlet時輸出如下:
hi kitty!
則應在此Servlet下划線處填充如下代碼。(選項一項)
a) PrintWriter out = response.getWriter();
b) PrintWriter out = request.getWriter();
c) OutputStream out = response.getOutputStream();
d) OutputStream out = request.getWriter();
11)給定如下JSP代碼,假定在瀏覽器中輸入URL:http://localhost:8080/web/jsp1.jsp,可以調用這個JSP,那么這個JSP的輸出是()。(選項一項)
<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri=”http://java.sun.com/jsp/jstl/core” prefix=”c”%>
<html>
<body>
<% int counter = 10; %>
<c:if test=”${counter%2==1}”>
<c:set var=”isOdd” value=”true”></c:set>
</c:if>
<c:choose>
<c:when test=”${isOdd==true}”>it’s an odd </c:when>
<c:otherwise>it’s an even </c:otherwise>
</c:choose>
</body>
</html>
a) 一個HTML頁面,頁面上顯示it’s an odd
b) 一個HTML頁面,頁面上顯示it’s an even
c) 一個空白的HTML頁面
d) 錯誤信息
12) 給定java程序User.java,代碼如下:
package user;
public class User{
private String password;
private String loginName;
public String getLoginName(){
return loginName;
}
public String getPassword(){
return password;
}
public void setLoginName(String loginName){
this.loginName=loginName;
}
public void setPassword(String password){
this.password=password;
}
}
給定user.jsp,代碼片斷如下:
____________
loginName: <jsp:getProperty name=”user” property=”loginName”/>
password: <jsp:getProperty name=”user” property=”password”/>
在瀏覽器上輸入URL:http://localhost/user,jsp?loginName=sa&password=sa並回車
要使瀏覽器上顯示:
loginName: sa password: sa
在user.jsp中的下划線處應填入以下()代碼. (選擇一項)
a) <jsp:useBean id=”user” class=”user.User” scope=”page”/>
<jsp:setProperty name=”user” property=”loginName” value=”*”/>
<jsp:setProperty name=”user” property=”password” value=”*”/>
b) <jsp:useBean id=”user” class=”user.User” scope=”application”/>
<jsp:setProperty name=”user” property=”loginName” value=”*”/>
<jsp:setProperty name=”user” property=”password” value=”*”/>
c) <jsp:useBean id=”user” class=”user.User” scope=” application”/>
<jsp:setProperty name=”user” property=”*” />
d) <jsp:useBean id=”user” class=”user.User” scope=” page”/>
<jsp:setProperty name=”user” property=”*” />
13) 某JSP程序中聲明使用javaBean的語句如下:
<jsp:useBean id=”user” class=”mypackage.User” scope=”pge”/>
要取出該javaBean的loginName屬性值,以下語句正確的是(). (選擇兩項)
a) <jsp:getProperty name=”user” property=”loginName’/>
b) <jsp:getProperty id=”user’ property=”loginName”/>
c) <%=user.getLoginName()%>
d) <%=user.getProperty(“loginName”)%>
14) J2EE中,以下關於HttpServlet的說法錯誤的是()。(選擇一項)
a) HttpServlet是一個抽象類
b) HttpServlet類擴展了GenericServlet類
c) HttpServlet類的子類必須至少重寫service方法
d) HttpServlet位於javax.servlet.http包中
15)給頂一個JSP程序源代碼,如下:
<jsp:include page="two.jsp" flush="true">
<jsp:param name="location" value="bejing"/>
</jsp:include>
在two.jsp中使用()代碼片段可以輸出參數location的值。
a) <jsp:getParam name="location">
b) <jsp:getParameter name="location">
c) <%=request.getAttribute("location")%>
d) <%=request.getParameter("location")%>
16)J2EE中,JSP EL表達式:s{(10*10) ne 100}的值是()。(選擇一項)
a) 0 b) True
c) False d) 1
17)在J2EE中,test.jsp文件如下:
<html>
<%{%>
<jsp:useBean id="buffer"scope="page" type="java.lang.StringBuffer"/>
<% buffer.append("ABC");%>
<%}%> buffer is <%=buffer%>
</html>
運行時,將發生()。 (選擇一項)
a) 轉譯期錯誤 b) 運行期錯誤
c) 運行后,瀏覽器上顯示:buffer is null
d) 運行后,瀏覽器上顯示:buffer is ABC
18) 如JSP頁面執行時遇到自定義標簽,doStartTag()方法將被調用()次。(選擇一項)
a) 1 b) 1或多
c) 0或1 d) 0或多
19) 給定include1.jsp文件代碼片斷,如下:
<% pageContext.setAttribute("User","HAHA");%>
_______//此處填寫代碼
給定include2.jsp文件代碼片斷,如下:
<%=pageContext.getAttribute("User")%>
要求運行include1.jsp時,瀏覽器上輸出:HAHA
要滿足以上條件,jsp1.jsp中下划線處應填入以下()語句。(選擇一項)
a) <jsp:include page="include2.jsp" flush="true"/>
b) <%@ include file="include2.jsp"%>
c) <jsp:forword page="include2.jsp"/>
d) <% response.sendRedirect("include2.jsp");%>
20)在J2EE中,在web.xml中,有如下代碼:
<session - config>
<session - timeout>30</session - timeout>
</session - config>
上述代碼定義了默認的會話超時時長,時長為30( )。(選擇一項)
a) 毫秒 b) 秒
c) 分鍾 d) 小時
21) 在inc.jsp中包含數行代碼與一張圖片,現在要創建一個home.jsp,每次瀏覽home.jsp時都能夠以最快的速度顯示inc.jsp中的所有內容以及home.jsp自身要顯示的內容,應該在home.jsp中使用的語句是( )。(選擇一項)
a) <%@include file = “inc.jsp”%> b)<%@include page=“inc.jsp”flush= “true”>
c) <jsp:include file = “inc.jsp”flush = “false”> d) <jsp:forward page = “inc.jsp”/>
22) 給定一個JSP程序源碼如下:
<jsp:include page = “two.jsp”flush = “true”>
<jsp:param name = “location”value = “beijing”/>
</jsp:include>
在two.jsp中加入( )代碼片斷可以輸出參數location的值。(選擇一項)
a) <jsp:getParam name = “location”> b) <jsp:getParameter name = “location”>
c) <% = request.getAttribute(“location”)%> d)<% = request.getParameter(“location”)%>
23)使用自定義標簽時,要為JSP引擎提供有關自定義標簽的相關信息,下列信息描述語句正確的是( )。(選擇一項)
a)<tag>
<name>hello</name>
<tag-class>com.tagdemo.HelloTag</tag-class>
</tag>
b)<taglib>
<name>hello</name>
<tag-class>com.tagdemo.HelloTag</tag-class>
</taglib>
c)<tag-info>
<name>hello</name>
<tagclass>com.tagdemo.HelloTag</tagclass>
</tag-info>
d)<tag-desc>
<name>hello</name>
<tagclass>com.tagdemo.HelloTag</tagclass>
</tag-desc>
24) 要設置某個JSP頁面為錯誤處理頁面,以下page指令正確的是()。 (選擇一項)
a) <%@ page errorPage="true"%> b) <%@ page isErrorPage="true"%>
c) <%@ page extends="javax.servlet.jsp.JspErrorPage"%>
d) <%@ page info="error"%>
25)JavaMail是一組用於發送和接收郵件消息的API。發送郵件使用()協議,接收郵件使用()協議。 (選擇一項)
a) POP3 SMTP b) POP3 TCP
c) SMTP TCP d) SMTP POP3
26) 在Servlet里,能正確獲取session的語句是()。 (選擇一項)
a) HttpSession session = request.getSession(true);
b) HttpSession session = request.getHttpSession(true);
c) HttpSession session = response.getSession(true);
d) HttpSession session = response. getHttpSession (true);
27) 在JSP中,()動作用於將請求轉發給其他JSP頁面。 (選擇一項)
a) forward b) include
c) useBean d) setProperty
28) 在J2EE中,在一個JSP文件中,有表達式<%=2+3 %>,它將輸出()。 (選擇一項)
a) 2+3 b) 5
c) 23 d) 不會輸出,因為表達式是錯誤的
29) 在J2EE實現企業級應用開發中,()是描述標記庫的XML文檔。 (選擇一項)
a) TLD文件 b) DTD文件
c ) WAR文件 d) EAR文件
30) 給定JSP程序源碼如下,可以在下划線處插入並且能夠正確輸出WELCOME,JACK的語句是()。 (選擇二項)
<html>
<body>
<% String name="JACK"; %>
WELCOME,______
</body></html>
a) name b) <%=name%>
c) out.println(name); d) <% out.println(name); %>
31)在J2EE中,重定向到另一個頁面,以下()語句是正確的。 (選擇一項)
a) request.sendRedirect("http://www.jb-aptech.com.cn");
b) request.sendRedirect();
c) response.sendRedirect("http://www.jb-aptech.com.cn");
d) response.sendRedirect();
32) 在JSP中,使用<jsp:useBean>動作可以將javaBean嵌入JSP頁面,對JavaBean的訪問范圍不能是()。 (選擇一項)
a) page b) request
c) response d) application
33) 在J2EE中,使用Servlet過濾器時,可以在web.xml文件的()元素中包括<init-param>元素。 (選擇一項)
a) <filter> b) <filter-mapping>
c) <filter-name> d) <filter-class>
34) Servlet中,使用()接口中定義的()方法來處理客戶端發出的表單數據請求 (選一項)
a) HttpServlet doHead b) HttpServlet doPost
c) ServletRequest doGet d) ServletRequest doPost
35) 給定JSP程序源碼如下,該JSP運行后輸出的結果是()。 (選擇一項)
<html>
<% int count =1;%> Count: <% ++count; %>
</html>
a) Count:1 b) Count:2
c) 1:2 d) Count:
36) 給定如下Servlet代碼,假定在瀏覽器中輸入URL:http://localhost:8080/servlet/HelloServlet,可以調用這個servlet,那么這個Servlet的輸出是()。
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloServlet extends HttpServlet{
public void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException{
}
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("<html>");
out.println("<body>");
out.println("doGet Hello World!");
out.println("</body>");
out.println("</html>");
out.close();
}
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("<html>");
out.println("<body>");
out.println("doPost Hello World!");
out.println("</body>");
}
} (選擇一項)
a) 一個HTML頁面,頁面上顯示doGet Hello World!
b) 一個HTML頁面,頁面上顯示doPost Hello World!
c) 一個空白的HTML頁面
d) 錯誤信息
37) 在J2EE中,request對象的( )方法可以獲取頁面請求中一個表單組件對應多個值時的用戶的請求數據。(選擇一項)
a) String getParameter(String name)
b) String[] getParameter(String name)
c) String getParameterValuses(String name)
d) String[] getParameterValues(String name)
38)( )是發送郵件的協議。(選擇一項)
a) SMTP b) LAMP
c) POP3 d) HTTP
39) WEB應用中,常用的會話跟蹤方法不包括()。(選擇一項)
a) URL重寫 b) Cookie
c) 隱藏表單域 d) 有狀態HTTP協議
40) 在J2EE中,${2 + “4”}將輸出()。(選擇一項)
a) 2 + 4 b) 6
c) 24 d) 不會輸出,因為表達式是錯誤的
41) 在J2EE的Model Ⅱ模式中,模型層對象被編寫為()。(選擇一項)
a) Applet b) JSP
c) Server d) JavaBean
42) J2EE中,JSP EL 表達式:${user.loginName}執行效果等同於()。(選擇一項)
a) <% = user.getLoginName()%> b) <%user.getLoginName();%>
c) <% = user.loginName%> d) <% user.loginName;%>
43) J2EE中,()類()方法用於返回應用程序的上下文路徑。(選擇一項)
a) HttpServletRequest、getContextPath() b) HttpServletRequset、getPathInfo()
c) ServletContext、getContextPath() d) ServletContext、getPathInfo()
44) 在J2EE中,使用Servlet過濾器時,需要在web.xml通過()元素將過濾器映射到Web資源。(選擇一項)
a) <filter> b) <filter-mapping>
c) <servlet> d) <servlet-mapping>
45) 給定JSP程序源碼如下:
<html>
<% int count =1;%> _______
</html>
以下()語句可以在下划線處插入,並且運行后輸出結果是:1。 (選擇一項)
a) <%=++count %> b) <% ++count; %>
c) <% count++; %> d) <% =count++ %>
46) 在J2EE中,在web.xml中定義過濾器時可以指定初始化參數,以下定義正確的是()(選擇一項)
a) <filter>
<filter-name>someFilter</filter-name>
<filter-class>filters.SomeFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>EUC_JP</param-value>
</init-param>
</filter>
b) <filter>
<fiter-name>someFilter</filter-name>
<init-param>
<param-name>encoding</param-name>
<plaram-value>EUC_JP</param-value>
</init-param>
</filter>
c) <filter-mapping>
<filter-name>someFilter</filter-name>
<init-param>
<param-name>encoding</param-name>
<param-value>EUC_JP</param-value>
</init-param>
</filter-mapping>
d) <filter-mapping>
<filter-name>someFilter</filter-name>
<filter-class>filters.SomeFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>EUC_JP</param-value>
</init-param>
</filter-mapping>
47) servlet 的生命周期又一系列事件組成,把這些事件按照先后順序排序,以下正確的是()(選擇一項)
a) 加載類,實例化,請求處理,初始化,銷毀
b) 加載類,實例化,初始化,請求處理,銷毀
c) 實例化,加載類,初始化,請求處理,銷毀
d) 加載類,初始化,實例化,請求處理,銷毀
48) 在J2EE中,給定某Servlet的代碼如下,編譯運行該文件,以下陳述正確的是()。(選擇一項)
Public class Servlet1 extends HttpServlet{
Public void init() throws ServletException{
}
Public void service(HttpServletRequest request,HttpServletResponse response)
Throws ServletException,IOException{
PrintWriter out = response.getWriter();
Out.println(“hello!”);
}
}
a) 編譯該文件時會提示缺少doGet()或者dopost()方法,編譯不能夠成功通過
b) 編譯后,把Servlet1.class放在正確位置,運行該Servlet,在瀏覽器中會看到輸出文字:hello!
c) 編譯后,把Servlet1.class放在正確位置,運行該Servlet,在瀏覽器中看不到任何輸出的文字
d) 編譯后,把Servlet1.class放在正確位置,運行該Servlet,在瀏覽器中會看到運行期錯誤信息
49)某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中,有一個名為ProcessServlet.class的文件
b) 該servlet的訪問路徑是http://機器IP:端口號/root/proc
c) 該servlet的訪問路徑是http://機器IP:端口號/root/ProcessServlet
d) 該servlet的訪問路徑是http://機器IP:端口號/root/ProcessServlet
50) 在J2EE中,test.jsp文件中有如下一行代碼:
<jsp:useBean id=”user” scope=”__” type=”com.UserBean”>
要使user對象可以作用於整個應用程序,下划線中應添入()。(選擇一項)
a) page b) request
c) session d) application
1)在J2EE中,<%=2+4%>將輸出(6)。(選擇一項)
a) 2+4
b) 6
c) 24
d) 不會輸出,因為表達式是錯誤的
2)在J2EE中,request對象的()方法可以獲取頁面請求中一個表單組件對應多個值時的用戶的請求數據。(選擇一項)
a) String getParameter(String name)
b) String[] getParameter(String name)
c) String getParameterValues(String name)
d) String[] getParameterValues(String name)
3)()是發送郵件的協議。(選擇一項)
a) SMTP
b) IAMP
c) POP3
d) HTTP
4)J2EE中,JSP EL表達式:${user.loginName}的執行效果等同於()。(選擇一項)
a) <%=user.getLoginName()%>
b) <% user.getLoginName();%>
c) <%=user.loginName%>
d) <% user.loginName;%>
5) 在J2EE中,test.jsp文件中有如下一行代碼:
<jsp:useBean id=”user”scope=”_”type=”com.UserBean”/>
要使user對象只能在使用test.jsp時使用,當加載頁面時就會將其銷毀。下划線中應填入()。(選擇一項)
a) page
b) request
c) session
d) application
6)要設計一個大型的基於多層體系結構的web應用系統,系統界面端基於HTML和XML,
該系統要不斷的進行版本升級(即日后維護、二次需求開發等任務量較大),要達成這些目
標,最適合的開發模式是()。(選擇一項)
a) DAO
b) ValueObject
c) MVC
d) Proxy
7) 在J2EE中,使用Servlet過濾器時,需要在web.xml通過()元素將過濾器映射到Web資源。(選擇一項)
a) <filter>
b) <filter-mapping>
c) <servlet>
d) <servlet-mapping>
8)在J2EE的Model II模式中,模型層對象被編寫為()。(選擇一項)
a) Applet
b) JSP
c) Servlet
d) JavaBean
9) J2EE中,()類的()方法用於返回應用程序的上下文路徑。(選擇一項)
a) HttpServletRequest、getContextPath()
b) HttpServletRequest、getPathInfo()
c) ServlettContext、getContextPath()
d) ServlettContext、getPathInfo()
10)Web應用中,常用的會話跟蹤方法不包括()。(選擇一項)
a) URL重寫
b) Cookie
c) 隱藏表單域
d) 有狀態HTTP協議
針對以下題目請選擇正確的答案(每道題目有一個或多哥正確的答案)。每一道題目,所有答案都選對,則該題加分,所選答案錯誤或不能選出所有正確答案,則該題不得分。
1)在JSP中,要定義一個方法,需要用到以下()元素。(選擇一項)
a) <%= %> b) <% %>
c) <%! %> d) <%@ %>
2)JSP頁面經過編譯之后,將創建一個()。(選擇一項)
a) applet b) servlet
c) application d) exe文件
3)當JSP頁面執行自定義標簽,遇到結束標簽時將調用()方法執行處理。(選擇一項)
a) doStartTag() b) doEndTag()
c) doInitBody() d) doAfterBody()
4) 在J2EE中,test.jsp文件中有如下一行代碼:(選擇一項)
<jsp:useBean id=”user” scope=”_____” type=”com.UserBean”/>
要使user對象中一直存在於對話中,直至其終止或被刪除為止,下划線中應填入()。
a) page b) request
c) session d) application
5) 在J2EE中,以下不是JSP隱式對象的是()。(選擇一項)
a) pageContext b) context
c) application d) out
6) Servlet中,HttpServletResponse的()方法用來把一個Http請求重定向到另外的URL。(選擇一項)
a) sendURL() b) redirectURL()
c) sendRedirect() d) redirectResponse()
7) 在JSP中,page指令的()屬性用來引入需要的包或類。(選擇一項)
a) extends b) import
c) languge d) contentType
8) 在Servlet過濾器的生命周期方法中,每當傳遞請求或響應時,web容器會調用()方法。(選擇一項)
a) init b) service
c) doFilter d) destroy
9) 在JSP中,只有一行代碼:<%=’A’+’B’%>,運行將輸出()。(選擇一項)
a) A+B b) AB
c) 131 d) 錯誤信息,因為表達式是錯誤的
10)給定一個Servlet的代碼片段如下:
Public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException{
______
out.println(“hi kitty!”);
out.close();
}
運行次Servlet時輸出如下:
hi kitty!
則應在此Servlet下划線處填充如下代碼。(選項一項)
a) PrintWriter out = response.getWriter();
b) PrintWriter out = request.getWriter();
c) OutputStream out = response.getOutputStream();
d) OutputStream out = request.getWriter();
11)給定如下JSP代碼,假定在瀏覽器中輸入URL:http://localhost:8080/web/jsp1.jsp,可以調用這個JSP,那么這個JSP的輸出是()。(選項一項)
<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri=”http://java.sun.com/jsp/jstl/core” prefix=”c”%>
<html>
<body>
<% int counter = 10; %>
<c:if test=”${counter%2==1}”>
<c:set var=”isOdd” value=”true”></c:set>
</c:if>
<c:choose>
<c:when test=”${isOdd==true}”>it’s an odd </c:when>
<c:otherwise>it’s an even </c:otherwise>
</c:choose>
</body>
</html>
a) 一個HTML頁面,頁面上顯示it’s an odd
b) 一個HTML頁面,頁面上顯示it’s an even
c) 一個空白的HTML頁面
d) 錯誤信息
12) 給定java程序User.java,代碼如下:
package user;
public class User{
private String password;
private String loginName;
public String getLoginName(){
return loginName;
}
public String getPassword(){
return password;
}
public void setLoginName(String loginName){
this.loginName=loginName;
}
public void setPassword(String password){
this.password=password;
}
}
給定user.jsp,代碼片斷如下:
____________
loginName: <jsp:getProperty name=”user” property=”loginName”/>
password: <jsp:getProperty name=”user” property=”password”/>
在瀏覽器上輸入URL:http://localhost/user,jsp?loginName=sa&password=sa並回車
要使瀏覽器上顯示:
loginName: sa password: sa
在user.jsp中的下划線處應填入以下()代碼. (選擇一項)
a) <jsp:useBean id=”user” class=”user.User” scope=”page”/>
<jsp:setProperty name=”user” property=”loginName” value=”*”/>
<jsp:setProperty name=”user” property=”password” value=”*”/>
b) <jsp:useBean id=”user” class=”user.User” scope=”application”/>
<jsp:setProperty name=”user” property=”loginName” value=”*”/>
<jsp:setProperty name=”user” property=”password” value=”*”/>
c) <jsp:useBean id=”user” class=”user.User” scope=” application”/>
<jsp:setProperty name=”user” property=”*” />
d) <jsp:useBean id=”user” class=”user.User” scope=” page”/>
<jsp:setProperty name=”user” property=”*” />
13) 某JSP程序中聲明使用javaBean的語句如下:
<jsp:useBean id=”user” class=”mypackage.User” scope=”pge”/>
要取出該javaBean的loginName屬性值,以下語句正確的是(). (選擇兩項)
a) <jsp:getProperty name=”user” property=”loginName’/>
b) <jsp:getProperty id=”user’ property=”loginName”/>
c) <%=user.getLoginName()%>
d) <%=user.getProperty(“loginName”)%>
14) J2EE中,以下關於HttpServlet的說法錯誤的是()。(選擇一項)
a) HttpServlet是一個抽象類
b) HttpServlet類擴展了GenericServlet類
c) HttpServlet類的子類必須至少重寫service方法
d) HttpServlet位於javax.servlet.http包中
15)給頂一個JSP程序源代碼,如下:
<jsp:include page="two.jsp" flush="true">
<jsp:param name="location" value="bejing"/>
</jsp:include>
在two.jsp中使用()代碼片段可以輸出參數location的值。
a) <jsp:getParam name="location">
b) <jsp:getParameter name="location">
c) <%=request.getAttribute("location")%>
d) <%=request.getParameter("location")%>
16)J2EE中,JSP EL表達式:s{(10*10) ne 100}的值是()。(選擇一項)
a) 0 b) True
c) False d) 1
17)在J2EE中,test.jsp文件如下:
<html>
<%{%>
<jsp:useBean id="buffer"scope="page" type="java.lang.StringBuffer"/>
<% buffer.append("ABC");%>
<%}%> buffer is <%=buffer%>
</html>
運行時,將發生()。 (選擇一項)
a) 轉譯期錯誤 b) 運行期錯誤
c) 運行后,瀏覽器上顯示:buffer is null
d) 運行后,瀏覽器上顯示:buffer is ABC
18) 如JSP頁面執行時遇到自定義標簽,doStartTag()方法將被調用()次。(選擇一項)
a) 1 b) 1或多
c) 0或1 d) 0或多
19) 給定include1.jsp文件代碼片斷,如下:
<% pageContext.setAttribute("User","HAHA");%>
_______//此處填寫代碼
給定include2.jsp文件代碼片斷,如下:
<%=pageContext.getAttribute("User")%>
要求運行include1.jsp時,瀏覽器上輸出:HAHA
要滿足以上條件,jsp1.jsp中下划線處應填入以下()語句。(選擇一項)
a) <jsp:include page="include2.jsp" flush="true"/>
b) <%@ include file="include2.jsp"%>
c) <jsp:forword page="include2.jsp"/>
d) <% response.sendRedirect("include2.jsp");%>
20)在J2EE中,在web.xml中,有如下代碼:
<session - config>
<session - timeout>30</session - timeout>
</session - config>
上述代碼定義了默認的會話超時時長,時長為30( )。(選擇一項)
a) 毫秒 b) 秒
c) 分鍾 d) 小時
21) 在inc.jsp中包含數行代碼與一張圖片,現在要創建一個home.jsp,每次瀏覽home.jsp時都能夠以最快的速度顯示inc.jsp中的所有內容以及home.jsp自身要顯示的內容,應該在home.jsp中使用的語句是( )。(選擇一項)
a) <%@include file = “inc.jsp”%> b)<%@include page=“inc.jsp”flush= “true”>
c) <jsp:include file = “inc.jsp”flush = “false”> d) <jsp:forward page = “inc.jsp”/>
22) 給定一個JSP程序源碼如下:
<jsp:include page = “two.jsp”flush = “true”>
<jsp:param name = “location”value = “beijing”/>
</jsp:include>
在two.jsp中加入( )代碼片斷可以輸出參數location的值。(選擇一項)
a) <jsp:getParam name = “location”> b) <jsp:getParameter name = “location”>
c) <% = request.getAttribute(“location”)%> d)<% = request.getParameter(“location”)%>
23)使用自定義標簽時,要為JSP引擎提供有關自定義標簽的相關信息,下列信息描述語句正確的是( )。(選擇一項)
a)<tag>
<name>hello</name>
<tag-class>com.tagdemo.HelloTag</tag-class>
</tag>
b)<taglib>
<name>hello</name>
<tag-class>com.tagdemo.HelloTag</tag-class>
</taglib>
c)<tag-info>
<name>hello</name>
<tagclass>com.tagdemo.HelloTag</tagclass>
</tag-info>
d)<tag-desc>
<name>hello</name>
<tagclass>com.tagdemo.HelloTag</tagclass>
</tag-desc>
24) 要設置某個JSP頁面為錯誤處理頁面,以下page指令正確的是()。 (選擇一項)
a) <%@ page errorPage="true"%> b) <%@ page isErrorPage="true"%>
c) <%@ page extends="javax.servlet.jsp.JspErrorPage"%>
d) <%@ page info="error"%>
25)JavaMail是一組用於發送和接收郵件消息的API。發送郵件使用()協議,接收郵件使用()協議。 (選擇一項)
a) POP3 SMTP b) POP3 TCP
c) SMTP TCP d) SMTP POP3
26) 在Servlet里,能正確獲取session的語句是()。 (選擇一項)
a) HttpSession session = request.getSession(true);
b) HttpSession session = request.getHttpSession(true);
c) HttpSession session = response.getSession(true);
d) HttpSession session = response. getHttpSession (true);
27) 在JSP中,()動作用於將請求轉發給其他JSP頁面。 (選擇一項)
a) forward b) include
c) useBean d) setProperty
28) 在J2EE中,在一個JSP文件中,有表達式<%=2+3 %>,它將輸出()。 (選擇一項)
a) 2+3 b) 5
c) 23 d) 不會輸出,因為表達式是錯誤的
29) 在J2EE實現企業級應用開發中,()是描述標記庫的XML文檔。 (選擇一項)
a) TLD文件 b) DTD文件
c ) WAR文件 d) EAR文件
30) 給定JSP程序源碼如下,可以在下划線處插入並且能夠正確輸出WELCOME,JACK的語句是()。 (選擇二項)
<html>
<body>
<% String name="JACK"; %>
WELCOME,______
</body></html>
a) name b) <%=name%>
c) out.println(name); d) <% out.println(name); %>
31)在J2EE中,重定向到另一個頁面,以下()語句是正確的。 (選擇一項)
a) request.sendRedirect("http://www.jb-aptech.com.cn");
b) request.sendRedirect();
c) response.sendRedirect("http://www.jb-aptech.com.cn");
d) response.sendRedirect();
32) 在JSP中,使用<jsp:useBean>動作可以將javaBean嵌入JSP頁面,對JavaBean的訪問范圍不能是()。 (選擇一項)
a) page b) request
c) response d) application
33) 在J2EE中,使用Servlet過濾器時,可以在web.xml文件的()元素中包括<init-param>元素。 (選擇一項)
a) <filter> b) <filter-mapping>
c) <filter-name> d) <filter-class>
34) Servlet中,使用()接口中定義的()方法來處理客戶端發出的表單數據請求 (選一項)
a) HttpServlet doHead b) HttpServlet doPost
c) ServletRequest doGet d) ServletRequest doPost
35) 給定JSP程序源碼如下,該JSP運行后輸出的結果是()。 (選擇一項)
<html>
<% int count =1;%> Count: <% ++count; %>
</html>
a) Count:1 b) Count:2
c) 1:2 d) Count:
36) 給定如下Servlet代碼,假定在瀏覽器中輸入URL:http://localhost:8080/servlet/HelloServlet,可以調用這個servlet,那么這個Servlet的輸出是()。
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloServlet extends HttpServlet{
public void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException{
}
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("<html>");
out.println("<body>");
out.println("doGet Hello World!");
out.println("</body>");
out.println("</html>");
out.close();
}
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("<html>");
out.println("<body>");
out.println("doPost Hello World!");
out.println("</body>");
}
} (選擇一項)
a) 一個HTML頁面,頁面上顯示doGet Hello World!
b) 一個HTML頁面,頁面上顯示doPost Hello World!
c) 一個空白的HTML頁面
d) 錯誤信息
37) 在J2EE中,request對象的( )方法可以獲取頁面請求中一個表單組件對應多個值時的用戶的請求數據。(選擇一項)
a) String getParameter(String name)
b) String[] getParameter(String name)
c) String getParameterValuses(String name)
d) String[] getParameterValues(String name)
38)( )是發送郵件的協議。(選擇一項)
a) SMTP b) LAMP
c) POP3 d) HTTP
39) WEB應用中,常用的會話跟蹤方法不包括()。(選擇一項)
a) URL重寫 b) Cookie
c) 隱藏表單域 d) 有狀態HTTP協議
40) 在J2EE中,${2 + “4”}將輸出()。(選擇一項)
a) 2 + 4 b) 6
c) 24 d) 不會輸出,因為表達式是錯誤的
41) 在J2EE的Model Ⅱ模式中,模型層對象被編寫為()。(選擇一項)
a) Applet b) JSP
c) Server d) JavaBean
42) J2EE中,JSP EL 表達式:${user.loginName}執行效果等同於()。(選擇一項)
a) <% = user.getLoginName()%> b) <%user.getLoginName();%>
c) <% = user.loginName%> d) <% user.loginName;%>
43) J2EE中,()類()方法用於返回應用程序的上下文路徑。(選擇一項)
a) HttpServletRequest、getContextPath() b) HttpServletRequset、getPathInfo()
c) ServletContext、getContextPath() d) ServletContext、getPathInfo()
44) 在J2EE中,使用Servlet過濾器時,需要在web.xml通過()元素將過濾器映射到Web資源。(選擇一項)
a) <filter> b) <filter-mapping>
c) <servlet> d) <servlet-mapping>
45) 給定JSP程序源碼如下:
<html>
<% int count =1;%> _______
</html>
以下()語句可以在下划線處插入,並且運行后輸出結果是:1。 (選擇一項)
a) <%=++count %> b) <% ++count; %>
c) <% count++; %> d) <% =count++ %>
46) 在J2EE中,在web.xml中定義過濾器時可以指定初始化參數,以下定義正確的是()(選擇一項)
a) <filter>
<filter-name>someFilter</filter-name>
<filter-class>filters.SomeFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>EUC_JP</param-value>
</init-param>
</filter>
b) <filter>
<fiter-name>someFilter</filter-name>
<init-param>
<param-name>encoding</param-name>
<plaram-value>EUC_JP</param-value>
</init-param>
</filter>
c) <filter-mapping>
<filter-name>someFilter</filter-name>
<init-param>
<param-name>encoding</param-name>
<param-value>EUC_JP</param-value>
</init-param>
</filter-mapping>
d) <filter-mapping>
<filter-name>someFilter</filter-name>
<filter-class>filters.SomeFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>EUC_JP</param-value>
</init-param>
</filter-mapping>
47) servlet 的生命周期又一系列事件組成,把這些事件按照先后順序排序,以下正確的是()(選擇一項)
a) 加載類,實例化,請求處理,初始化,銷毀
b) 加載類,實例化,初始化,請求處理,銷毀
c) 實例化,加載類,初始化,請求處理,銷毀
d) 加載類,初始化,實例化,請求處理,銷毀
48) 在J2EE中,給定某Servlet的代碼如下,編譯運行該文件,以下陳述正確的是()。(選擇一項)
Public class Servlet1 extends HttpServlet{
Public void init() throws ServletException{
}
Public void service(HttpServletRequest request,HttpServletResponse response)
Throws ServletException,IOException{
PrintWriter out = response.getWriter();
Out.println(“hello!”);
}
}
a) 編譯該文件時會提示缺少doGet()或者dopost()方法,編譯不能夠成功通過
b) 編譯后,把Servlet1.class放在正確位置,運行該Servlet,在瀏覽器中會看到輸出文字:hello!
c) 編譯后,把Servlet1.class放在正確位置,運行該Servlet,在瀏覽器中看不到任何輸出的文字
d) 編譯后,把Servlet1.class放在正確位置,運行該Servlet,在瀏覽器中會看到運行期錯誤信息
49)某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中,有一個名為ProcessServlet.class的文件
b) 該servlet的訪問路徑是http://機器IP:端口號/root/proc
c) 該servlet的訪問路徑是http://機器IP:端口號/root/ProcessServlet
d) 該servlet的訪問路徑是http://機器IP:端口號/root/ProcessServlet
50) 在J2EE中,test.jsp文件中有如下一行代碼:
<jsp:useBean id=”user” scope=”__” type=”com.UserBean”>
要使user對象可以作用於整個應用程序,下划線中應添入()。(選擇一項)
a) page b) request
c) session d) application
1)在J2EE中,<%=2+4%>將輸出(6)。(選擇一項)
a) 2+4
b) 6
c) 24
d) 不會輸出,因為表達式是錯誤的
2)在J2EE中,request對象的()方法可以獲取頁面請求中一個表單組件對應多個值時的用戶的請求數據。(選擇一項)
a) String getParameter(String name)
b) String[] getParameter(String name)
c) String getParameterValues(String name)
d) String[] getParameterValues(String name)
3)()是發送郵件的協議。(選擇一項)
a) SMTP
b) IAMP
c) POP3
d) HTTP
4)J2EE中,JSP EL表達式:${user.loginName}的執行效果等同於()。(選擇一項)
a) <%=user.getLoginName()%>
b) <% user.getLoginName();%>
c) <%=user.loginName%>
d) <% user.loginName;%>
5) 在J2EE中,test.jsp文件中有如下一行代碼:
<jsp:useBean id=”user”scope=”_”type=”com.UserBean”/>
要使user對象只能在使用test.jsp時使用,當加載頁面時就會將其銷毀。下划線中應填入()。(選擇一項)
a) page
b) request
c) session
d) application
6)要設計一個大型的基於多層體系結構的web應用系統,系統界面端基於HTML和XML,
該系統要不斷的進行版本升級(即日后維護、二次需求開發等任務量較大),要達成這些目
標,最適合的開發模式是()。(選擇一項)
a) DAO
b) ValueObject
c) MVC
d) Proxy
7) 在J2EE中,使用Servlet過濾器時,需要在web.xml通過()元素將過濾器映射到Web資源。(選擇一項)
a) <filter>
b) <filter-mapping>
c) <servlet>
d) <servlet-mapping>
8)在J2EE的Model II模式中,模型層對象被編寫為()。(選擇一項)
a) Applet
b) JSP
c) Servlet
d) JavaBean
9) J2EE中,()類的()方法用於返回應用程序的上下文路徑。(選擇一項)
a) HttpServletRequest、getContextPath()
b) HttpServletRequest、getPathInfo()
c) ServlettContext、getContextPath()
d) ServlettContext、getPathInfo()
10)Web應用中,常用的會話跟蹤方法不包括()。(選擇一項)
a) URL重寫
b) Cookie
c) 隱藏表單域
d) 有狀態HTTP協議
1、下面哪一個不是JSP本身已加載的基本類?(b )
A、java.lang.* B、java.io.* C、javax.servlet.* D、javax.servlet.jsp.*
2、對於預定義<%!預定義%>的說法錯誤的是:(c)
A、一次可聲明多個變量和方法,只要以“;”結尾就行 B、一個聲明僅在一個頁面中有效
C、聲明的變量將作為局部變量 D、在預定義中聲明的變量將在JSP頁面初始化時初始化
3、從 “員工” 表的“姓名”字段中找出名字包含“瑪麗”的人,下面哪條select語句正確:( D )
A、 Select * from員工 where 姓名 =’_瑪麗_’ B 、Select * from員工 where 姓名 =’%瑪麗_’
C、 Select * from員工 where 姓名 like ‘_瑪麗%’ D、 Select * from員工 where 姓名 like ‘%瑪麗%’
4、下述選項中不屬於JDBC基本功能的是:( D )
A. 與數據庫建立連接 B. 提交SQL語句 C. 處理查詢結果 D. 數據庫維護管理
5、在JSP中使用<jsp:getProperty>標記時,不會出現的屬性是:( c )
A. name B. property C. value D. 以上皆不會出現
6、Page指令用於定義JSP文件中的全局屬性,下列關於該指令用法的描述不正確的是:(D )
A. <%@ page %>作用於整個JSP頁面。
B. 可以在一個頁面中使用多個<%@ page %>指令。
C. 為增強程序的可讀性,建議將<%@ page %>指令放在JSP文件的開頭,但不是必須的。
D. <%@ page %>指令中的屬性只能出現一次。
7、在JSP中調用JavaBean時不會用到的標記是:( A )
A. <javabean> B. <jsp:useBean> C. <jsp:setProperty> D. <jsp:getProperty>
8、關於JavaBean正確的說法是:( A)
A、Java文件與Bean所定義的類名可以不同,但一定要注意區分字母的大小寫
B、在JSP文件中引用Bean,其實就是用<jsp:useBean>語句
C、被引用的Bean文件的文件名后綴為.java
D、Bean文件放在任何目錄下都可以被引用
9、Servlet程序的入口點是:(A )
A、init() B、main() C、service() D、doGet()
10、 不能在不同用戶之間共享數據的方法是(A )
A、通過cookie B、利用文件系統 C、利用數據庫 D、通過ServletContext對象