级ee

来源:互联网 发布:网络摄像机镜头选择 编辑:程序博客网 时间:2024/04/29 02:31

Model2的组件

1. Which component is not belong to Model2c

A. Servlet       B.JSP        C. Web Component      D. Javaclass

 

servlet中用来转发请求的函数方法

2.Which is the method of servletfunctions used as a request’s dispatcher program?(a  

A. service()      B. init()         C. ServletResponse()         D. ServletRequest()

 

用来存放处理JSP ServletsJ2EEcontainer

3. Which J2EE container hosts JSPand Servlets?  d

A. Application Client Container   B. EJB Container   C. Web Server   D. Web Container

 

JSP的基本定义

4. Which description is correctabout JSP? b

A. It is convenient to code the scriptof client and server.

B. It is convenient to code the scriptof server.

C. It is convenient to code the scriptof client.

D. It is the script language ofMicrosoft.

 

RequestDispatcter接口的相关问题

6. Identify the description istrue or false?   a  

1) By using interface RequestDispatcter,the request from the servlet can be transferred to any other resources such as servlet,HTML file, or JSP page.

2) But by using interface RequestDispatcter,servlets in the same web context can not share resources.

A. True   False     B. False   True       C. False   False     D. True   True

 

servlet组件的配置文件名称

7. Which method of ServletContextListeneris called by web container after the web application run?   a

A. contextInitialized   B. initialContext C.contextDestroyed  D. contextInit

 

配置文件中“forward”脚本的使用

8. What is the function of thesub-tag forward of the tag action?  a )

A. Configure the mapping betweensymbolic name of views and URL

B. Configure the symbolic name ofviews

C. Configure the name of ACTIONclasses

D. Configure the alias of ACTIONclasses

 

JSP 页面中的declare标签

9. Which is used by JSP to putthe attribute into the HTTP response?   ( c

A. Using <% attribute name%>           B.Using <%! attribute name %>

C. Using <%= attribute name%>          D. Using <=attribute name >

 

filter的编程interface

10. If you want to code filterwhich interface should be implemented( c

A. ServletFilter interface               B. FilterServlet interface

C. Filter interface                      D. FilterChain interface

 

DataSource的定义

11. Which are the correct stepsto connect a database using DataSource? ( c

A. 1. using new to instantiate anobject of DataSource

2. call getConnection method onthe Connection object

3. using JDBC API through thisconnection to communicate with database

B. 1. execute JNDI lookup on nameservice to retrieve DataSource

2. call getConnection method onthe Connection object

3. using JDBC API through thisconnection to communicate with database

C. 1. using new to instantiate anobject of DataSource

2. call getConnection method onthe DataSource

3. using JDBC API through thisconnection to communicate with database

D. 1. execute JNDI lookup on nameservice to retrieve DataSource

2. call getConnection method onthe DataSource

3. using JDBC API through thisconnection to communicate with database

使用ServletRequest, ServletResponse and FilterChain参数的函数方法

13. Which method is equal to theservice method of servlet, and transfers three parameters: ServletRequest,ServletResponse and FilterChain?  ( c

A. Init      B. doGet      C. doFilter         D. destroy

 

ServletContext对象的概念

14. Which description is correctabout creating ServletContext object?  b

A. Be created by the web applicationitself when it was invoked

B. Be created by Container ofservlet for each web application when it was invoked    

C. Be created by Java webapplication itself for each HTTP request  

D. Be created by Container ofservlet for each HTTP request

 

HTTP SessionCookie的概念

15. Identify the description istrue or false?   b   

1) By using HTTP Session, anytype of data in the session can be traced.

2) However, using Cookie only thedata of string type can be saved.   

A. True   False     B. True   True      C. False   False      D. False  True

 

Session Facade pattern的使用目的

16. What is the purpose ofSession Facade pattern?a

A. It provides a service layer tothe clients exposing only those interfaces that are required for accessing theclients.         

B. It helps in reusing the codeby making use of the same helper for other views that contain similarfunctionality.        

C. It helps in modifying thelayout of the page.      

D. It helps in managing therequest authentication process, view management process and the error handlingprocess on the server side.

 

看懂代码<forward name=successpath=register/thank.view/>

18. The code followed is to configurethe struts: <forward name=”success” path=”register/thank.view”/>, whatcan the thank.view be? b

A. ActionForm     B. Servlet     C. JavaBean      D. DataSource

 

看懂代码ResultSet resultset =statement.executeQuery(select * From Customer)

19. Predict the output: b  

ResultSet resultset =statement.executeQuery(select * From Customer)?

A. Inserts data into the Customertable.     

B. Retrieves the data from theCustomer table and stores it into the variable resultset.

C. Stores the statement Select *From Customer into the variable resultset.   

D. Displays the result of theselect statement.   

 

EL访问Beanattribute的代码

28.  How to use EL to access Bean’s attributeb     

A.${bean.getAttribute()}             B.${bean.attribute} 

C.${bean.attribute()}                D<%=bean.attribute=>

 

1.什么叫servlet技术

列举出与传统Common Gateway Interface (CGI)相比的三个优点 .10’)

Java Servlets

(a)A servlet is a Java technologycomponent that executes on the server.

(b)Servlets perform tasks similarto those performed by CGI programs, but servlets

execute in a different environment.

(c) Servlets perform thefollowing:Process the HTTP request;Generate the HTTP response dynamically

(d)A web container is a specialJava? Virtual Machine (JVM?) that is responsible for maintaining

the life cycle of the servlets,as well as issuing threads for each request.

 

Java servlet advantages:

(a)Performance (threads arefaster than processes)

(b)Scalable

(c)The Java programming languageis robust and object-oriented

(d)The Java programming languageis platform independent

 

2. 比较HTTP GETHTTP POST方法的不同. 描述什么时候须使用HTTP POST方法,什么时候须使用HTTP GET方法.10’)

HTTP GET method:   Formdata is contained in the URL  of the HTTPrequest.1’)

HTTP POST method:  Form data is contained in the body  of the HTTP request.1’)

HTTP POST:

(a)The processing of the requestchanges the state of the server, such as storing data in a database.1’)

(b)The amount of form data is large.1’)

(c)The contents of the datashould not be visible in the URL (for example, passwords). 1’)

HTTP GET:

(a)The processing of the requestis idempotent.

(b)The amount of form data issmall.

(c)You want to allow the requestto be book marked.

 

3. 描述JSP页面处理的7个步骤.10’)11.8

(1)Translate the JSP to servletcode.

(2)Compile the servlet tobytecode.

(3)Load the servlet class.

(4)Create the servlet instance.

(5)Call the jspInit method.

(6)Call the _jspService method.

(7)Call the jspdestroy method.

 

4. 描述scripting elements5种类型

并写出他们的脚本语法格式. 10’)

Comment      <%-- comment --%>

Directive    <%@ directive %>

Declaration  <%! decl %>

Scriplet     <% code %>

Expression   <%= expr %>

 

 

编写一个简单的 html jsp 页面来做index页面。用来提供给用户输入他们的用户信息

Nam再编写一个 Servlet用来存储Session信息Name并把获取到的该信息发送到

另一个叫 Welcome Servlet 并显示信息如下“Welcome获取来的姓名to this website”.

1.首先新建一个html页面,主要代码如下:

<html>

 <head>

    <title>Please input yourName</title>

 </head>

 <body>

    Please input your name: <br>

    <form action="DispatcherServlet"method="post">

       name:<input type="text"name="name" size="20">

       <input type="submit"value="commit">

    </form>

    </body>

</html>

2.然后我们需要新建两个servlet,分别命名为DispatcherServletWelcomeServlet;

现在DispatcherServletservice方法中加入如下代码:

    Stringname = request.getParameter("name");

    request.getSession().setAttribute("name",name);

    request.getRequestDispatcher("WelcomeServlet").forward(request,response);

然后在WelcomeServletservice方法中添加如下代码,输出信息到response

    response.setContentType("text/html");

    PrintWriterout = response.getWriter();

    out.println("<!DOCTYPEHTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");

    out.println("<HTML>");

    out.println("  <HEAD><TITLE>AServlet</TITLE></HEAD>");

    out.println("  <BODY>");

    out.print("    Welcome ");        

    Stringname = (String) request.getSession().getAttribute("name");

    out.print(name);

    out.println("to this webSite!");

    out.println("  </BODY>");

    out.println("</HTML>");

    out.flush();

    out.close();

3.最后我们只需要做好相应的配置并部署到tomcat里面就可以了






1.Java Servlets(a)A servlet is aJava technology component that executes on the server(b)Servletsperform tasks similar to those performed by CGI programs, but servlets executein a different environment. (c) Servlets perform the following:Process the HTTPrequest;Generate the HTTP response dynamically.(d)A web container is a specialJava? Virtual Machine (JVM?) that is responsible for maintaining the life cycleof the servlets, as well as issuing threads for each request

Java servlet advantages: (a)Performance (threadsare faster than processes) (b)Scalable(c)The Java programming language isrobust and object-oriented(d)The Java programming language is platformindependent.

2.HTTP GET method:   Formdata is contained in the URL  of the HTTPrequest.

(a)The processing of the request is idempotent.(b)Theamount of form data is small.(c)You want to allow the request to be bookmarked.

HTTP POST method:  Form data is contained in the body  of the HTTP request.

(a)The processing of the request changes thestate of the server, such as storing data in a database.

(b)The amount of form data is large. (c)Thecontents of the data should not be visible in the URL (for example, passwords).

3.(1)Translate the JSP to servlet code.(2)Compilethe servlet to bytecode.(3)Load the servlet class.(4)Create the servletinstance.(5)Call the jspInit method.(6)Call the _jspService method.(7)Call thejspdestroy method.

4. Comment  <%-- comment --%> Directive    <%@ directive%>

Declaration  <%! decl %>  Scriplet     <% code %>  Expression   <%= expr %>



http://code.google.com/p/javastudy-wendell/downloads/list