CSU East Bay Computer Science Department
Mid1 Review2
SELECT THE BEST CHOICE (answer to the left of the question) (50%)
1. When a JSP is requested for the first time, the JSP
|a. |calls the servlet that it is associated with |
|b. |calls the built-in request object |
|c. |is converted into a servlet |
2. As you develop a web application, you typically use
|a. |JSPs for presentation and processing |
|b. |servlets for presentation and processing |
|c. |JSPs for processing and servlets for presentation |
|d. |JSPs for presentation and servlets for processing |
3. All but one of the following is true for a WAR (Web Archive) file. Which one is it?
|a. |A WAR file is a JAR file. |
|b. |A WAR file contains all the directories and files for a web application. |
|c. |When you deploy an application with a WAR file, the web server must be running. |
|d. |To deploy an application with a WAR file, you copy it into its document root directory. |
4. The servlets for a web application are stored in this directory and its subdirectories:
|a. |WEB-INF |c. |WEB-INF\lib |
|b. |WEB-INF\classes |d. |WEB-INF\servlets |
5. The web.xml file can do all but one of the following. Which one is it?
|a. |Define initialization parameters for a servlet. |
|b. |Define initialization parameters for the entire application. |
|c. |Enable servlet mapping so a client can call a servlet using any URL pattern. |
|d. |Set the web server port for the application. |
6. If you have to change the port that’s used by Tomcat, you make the change in the
|a. |server.xml file |c. |catalina.bat file |
|b. |web.xml file |d. |startup.bat file |
7. The following code
|a. |returns the name of all request parameters from the mail.jsp page |
|b. |returns the first value of the mail parameter or null if none exist |
|c. |returns all values of the mail parameter or null if none exist |
|d. |returns the values of all request parameters from the mail.jsp page |
|e. |is invalid |
8 .In general, you should use the Post method instead of the Get method when
|a. |the request writes data to the server |
|b. |the request reads data from the server |
|c. |you want users to be able to include parameters in their bookmarks |
|d. |when you’re transferring 4 KB or less of data |
9. To use your own Java class in a JSP, you can import the class with a
|a. |JSP scriptlet |c. |JSP directive |
|b. |JSP expression |d. |JSP declaration |
10. When a JSP is requested for the first time, the JSP engine does all but one of following. Which one is it?
|a. |generates a servlet for the JSP |
|b. |generates the HTML code for the JSP |
|c. |creates one instance of the servlet class |
|d. |creates one thread |
11. When a JSP is requested for the second time, the JSP engine
|a. |creates a thread that has its own copy of the instance variables |
|b. |creates a thread that has its own copy of the local variables |
|c. |creates an instance of the JSP that has its own copy of the instance variables |
|d. |creates an instance of the JSP that has its own copy of the local variables |
12. A servlet is a Java class that extends the
|a. |Servlet class |c. |HttpServlet class |
|b. |HttpGenericServlet class |d. |HttpServletRequest class |
13. In the code that follows, the servlet is mapped to
DiagnoseTrouble
/diagnostics/diagnoseTrouble
|a. |the /diagnostics/diagnoseTrouble URL of the document root directory |
|b. |the /diagnostics/diagnoseTrouble URL of the current directory |
|c. |any URL in the /diagnostics/diagnoseTrouble directory of the document root directory |
|d. |any URL in the /diagnostics/diagnoseTrouble directory of the current directory |
14. The init method of a servlet class is called
|a. |the first time a servlet is requested but before the service method |
|b. |each time the servlet is requested but before the service method |
|c. |the first time a servlet is requested but after the service method |
|d. |each time the servlet is requested but after the service method |
15. A session object is created
|a. |every time a browser makes a request for a web page |
|b. |every time a browser requests a servlet |
|c. |every time a browser requests a jsp |
|d. |the first time a browser requests a servlet or JSP from a web site |
16. A servlet can retrieve the current session object by using the getSession method of the
|a. |HttpSession class |c. |the request object |
|b. |response object |d. |the ServletContext object |
17. The current session object is available
|a. |only to JSPs |c. |to both servlets and JSPs |
|b. |only to servlets |
18. Which of the following statements is invalid?
|a. |String name = session.getAttribute("fullName"); |
|b. |Book book = (Book) session.getAttribute("bookObj"); |
|c. |session.setAttribute("fullName", "Ted Andrews"); |
|d. |session.removeAttribute("fullName"); |
19. When you use URL encoding for session tracking, you must
|a. |convert all HTML pages in the application to JSPs |
|b. |use the encodeURL method to encode all URLs in the JSPs |
|c. |use the encodeURL method to encode all URLs in the servlets |
|d. |a and b above |
|e. |a, b, and c above |
20. The cookie named mediaCookie in the following statement can be accessed by
mediaCookie.setPath("/");
|a. |only the current directory |c. |the entire web server |
|b. |the entire web application |d. |anyone |
21. The following Anchor tag demonstrates how to use
View your schedule
|a. |URL rewriting |c. |hidden fields |
|b. |URL encoding |d. |cookies |
22. When you use hidden fields to pass parameters to a servlet or JSP, all but one of the following is true. Which one is it?
|a. |the parameters aren’t shown in the URL |
|b. |the user can see the parameters by using the browser to look at the page’s source code |
|c. |you don’t have to store the parameters in the session object |
|d. |you can’t use URL encoding |
23. If you use the MVC pattern with EL,
|a. |the servlets create the JavaBeans and set the bean properties |
|b. |the servlets create the JavaBeans and the JSPs set the bean properties |
|c. |the JSPs create the JavaBeans and set the bean properties |
|d. |the JSPs create the JavaBeans and the servlets set the bean properties |
24. The initParam implicit object lets you use EL
|a. |to get the value of a context initialization parameter |
|b. |to get the value of a servlet initialization parameter |
|c. |to set the starting value of a context initialization parameter |
|d. |to set the starting value of a servlet initialization parameter |
25. Which of the following is the correct EL code for getting the value of a cookie named userPreference?
|a. |${cookie.userPreference} |
|b. |${cookie.userPreference.value} |
|c. |${cookie.value.userPreference} |
|d. |${cookie.userPreference[value]} |
FILL IN THE MISSING BLANKS (40%)
(Telnet, HTTP, JSPs, HTMLs, I/O, business, properties, attributes, choose, scripting, getInitParameter, TCP,
context, ServletContext, session, JSTL, include, web.xml, request, response, cookie, encodeURL, URL rewriting)
1. The (application) protocol that’s used by a client and a server to communicate in a web application is
________________________________________________.
2. When you use the Model 1 architecture, ________________________ handle both the request and response.
3. In the MVC pattern, the model consists of _________________________ objects.
4. When you use the MVC pattern, you often add ________________________ to the request object before you forward it to a JSP or another servlet.
5. To include a file in a JSP at compile-time, you use an include _____________________.
6. A parameter that’s available to the entire application is called a/an ___________________________ initialization parameter.
7. To get an initialization parameter, you use the ___________________________ method.
8. You can use getRealPath method of a/an ______________________________________ object to get the absolute path to a file that’s part of a web application.
9. To get the effect of an if/else statement with JSTL, you can use a/an _______________________ tag.
10. If you combine JSTL with EL and the MVC pattern, you should be able to remove most, if not all, of the __________________________ from your JSPs.
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- igcse computer science workbooks pdf
- igcse computer science workbook
- igcse computer science workbook answer
- igcse computer science coursebook pdf
- computer science people
- what is computer science like
- computer science revision
- igcse computer science revision notes
- college computer science project ideas
- ideas for computer science project
- computer science projects for students
- computer science final project