Title: Final
Course: CPS 278: Server Side Java ~ For IGNITE Review > Section: Assignments & Tests

Q: This question is based on the Mortgage problem defined in mortgage.htm.

On the mortgage.jsp page, if I want to use "m" instead of "mort" for the tags on lines 17, 19, 27, and 29, I would have to do which of the following:
- Change the package designator appropriately
- Store a variable named "m" using a setAttribute on the pageContext
- Change the value for the prefix attribute on line 1 in mortgage.jsp
- Update the mortgage tld to have an "m" parent class tag
- It can't be done
A: Change the value for the prefix attribute on line 1 in mortgage.jsp

Q: This question is based on the Mortgage problem defined in mortgage.htm.

On line 1 of the mortgage.jsp file, the "uri" attribute needs to have a value that satisfies which of the following properties:
- A proper URL that defines the properties of the tags used on this page.
- The value really isn't used.
- A proper URL for the host where the tags in this JSP will execute.
- Any unique value that matches the "uri" property in some tld file. Once tomcat finds a match, it expects to find definitions for all of the tags on this JSP page that have the corresponding prefix.
- The URI field needs to be filled in with a "User's Rightful Information"
A: Any unique value that matches the "uri" property in some tld file. Once tomcat finds a match, it expects to find definitions for all of the tags on this JSP page that have the corresponding prefix.

Q: This question is based on the Mortgage problem defined in mortgage.htm.

On line 12 of mortgage.jsp, you will see:

${principle}

The value that will be sent back to the browser will ______________.
- come from the request object from something like:
request.getParameter("principle")
- The value must come from a call to getAttribute from the request object like:
request.getAttribute("prinicple")
- The value must come from a call to getAttribute from the session object like:
session.getAttribute("prinicple")
- The value will be obtained from a call to getAttribute from one of the objects
pageContext, request, session, application (in that order).
- When JSP evaluates $(principle}, it will only look in pageContext, because of the way Expression Language works.
A: The value will be obtained from a call to getAttribute from one of the objects
pageContext, request, session, application (in that order).

Q: This question is based on the Mortgage problem defined in mortgage.htm.

On line 12 of mortgage.jsp, you will see:

${param.principle}

The value that will be sent back to the browser will ______________.
- come from the request object from something like:
request.getParameter("principle")
- The value must come from a call to getAttribute from the request object like:
request.getAttribute("prinicple")
- The value must come from a call to getAttribute from the session object like:
session.getAttribute("prinicple")
- The value will be obtained from a call to getAttribute from one of the objects
pageContext, request, session, application (in that order).
- When JSP evaluates $(principle}, it will only look in pageContext, because of the way Expression Language works.
A: come from the request object from something like:
request.getParameter("principle")

Q: This question is based on the Mortgage problem defined in mortgage.htm.

On line 12 of mortgage.jsp, you will see:

${param.principle}

The value that will be sent back to the browser will ______________.
- come from the request object from something like:
request.getParameter("principle")
- The value must come from a call to getAttribute from the request object like:
request.getAttribute("prinicple")
- The value must come from a call to getAttribute from the session object like:
session.getAttribute("prinicple")
- The value will be obtained from a call to getAttribute from one of the objects
pageContext, request, session, application (in that order).
- When JSP evaluates $(principle}, it will only look in pageContext, because of the way Expression Language works.
A: come from the request object from something like:
request.getParameter("principle")

Q: This question is based on the Mortgage problem defined in mortgage.htm.

In the Calc.java and Data.java classes click on all of the TRUE statements
- All of the output to the browser is generated in the doTag method.
- The content between the beginning of the mortgage_calc tag and the ending mortgage_calc will be sent to the browser each time that the following call is made:
getJspBody().invoke(null)
- Expression language constructs like:
${princ}
will be evaluated by a looking for a cookie named princ
- Expression language constructs like:
${princ}
will be evaluated by making a getAttribute call on one of the objects pageContext, request, session, application. The name passed to getAttribute will be "princ".
A: All of the output to the browser is generated in the doTag method.; The content between the beginning of the mortgage_calc tag and the ending mortgage_calc will be sent to the browser each time that the following call is made:
getJspBody().invoke(null); Expression language constructs like:
${princ}
will be evaluated by making a getAttribute call on one of the objects pageContext, request, session, application. The name passed to getAttribute will be "princ".

Q: This question is based on the Mortgage problem defined in mortgage.htm.

The content between the beginning of the mortgage_calc tag and the ending mortgage_calc can be:

(Click all that apply)
- html
- Scripts (like <%= Some Java expression %>
- Expression language constructs like:
${x}
- Text like:
"She sells sea shells down by the sea shore"
A: html; Expression language constructs like:
${x}; Text like:
"She sells sea shells down by the sea shore"

Q: This JSTL tag is used for something like a Java switch statement. Inside of this tag we should see "when" tags and perhaps an "otherwise" tag.
- line 1
- line 2
- line 3
- line 4
A: line 1

Q: This container class is used for a JSP page. It has the methods getAttribute and setAttribute.
EL variables can be stored in this container.
- Page
- PageContext
- JspContext
- Context
A: PageContext

Q: This is an Expression Language construct which could show up in a JSP page to access a variable with the name of "x".
- @(x)
- %{x}
- ${x}
- $[x]
A: ${x}

Q: This is an Expression Language construct which could show up in a JSP page to access the value of a cookie named "fred".
- %(cookie.fred)
- @{cookie.fred}
- ${cookie.fred}
- ${cookie.fred.value}
A: ${cookie.fred.value}

Q: This construct will inform a container like "Tomcat" that this page is using tags.
In this page, the prefix "fun" will be associated with the definitions found in a "tld" file
that contains a uri with the value of "http://wccnet.edu/chasselb/fun".
- line 1
- line 2
- line 3
- line 4
A: line 1

Q: A _______ is a class you would write to use for Expression language.
This kind of class often has the following basic properties:

All data should be private and have appropriate "getters/setters".
- Expression Bean
- Attribute Bean
- Java Bean
- Attribute
A: Java Bean

Q: This Expression Language will access a variable by the name of "state" and call the method "getName()".
- ${state[name]}
- ${state.name}
- ${state.getName}
- [state.name]
A: ${state.name}

Q: This method in the HttpServletResponse is useful for setting the "Mime-type" of the page being sent back.
Normally, this will default to: "text/html".
- setMimeType
- setText
- setDataType
- setContentType
A: setContentType

Q: This JSTL construct can be used to skip over JSP content if a variable named "cram" does not have the value "no"
- line 1
- line 2
- line 3
- line 4
A: line 3

Q: This Expression Language construct will effectively access"
request.getParameter("name")
- ${param.name}
- ${name}
- ${request.getName}
- ${parameter.name}
A: ${param.name}

Q: This JSTL construct will loop through a variable named "states".
- line 1
- line 2
- line 3
- line 4
A: line 2

Q: This JDBC Interface allows you to call methods which receive
SQL Strings as parameters.
- Connection
- ResultSet
- Statement
- SqlExec
A: Statement

Q: SQLExceptions have the following characteristics:
(Check all that apply)
- SQLExceptions are derived from RunTimeException, so it is optional whether you provide code to deal with this exception
- SQLExceptions are only thrown when you have a bad Connection.
- SQLExceptions are thrown when your SQL has a syntax error.
- Most JDBC calls need to be wrapped with
"try ... catch(SQLException e)" logic,
or else you have to add "throws SQLException" on the method containing the JDBC call.
A: SQLExceptions are thrown when your SQL has a syntax error.; Most JDBC calls need to be wrapped with
"try ... catch(SQLException e)" logic,
or else you have to add "throws SQLException" on the method containing the JDBC call.

Q: What is the advantage of using a PreparedStatement in JDBC?
- The SQL can be checked at Java Compile Time.
- If you prepare your statement you don't have to worry about exceptions from your JDBC call.
- A PreparedStatement in JDBC prepares Java to receive a lot of rows from a Select statement.
- The syntax can be checked once at Runtime, and the statement can be reused as many times as desired. The only thing changing on each execution is the data associated with the statement.
A: The syntax can be checked once at Runtime, and the statement can be reused as many times as desired. The only thing changing on each execution is the data associated with the statement.

Q: executeQuery is:
- a property of the Connection class that enables Select statements
- a class that contains the logic for creating SQL queries.
- An interface for SQL queries.
- A method of the Statement Interface that receives an SQL string and returns a ResultSet of data.
A: A method of the Statement Interface that receives an SQL string and returns a ResultSet of data.

Q: You execute the following instruction:
int retval = state.executeUpdate("update Data1 set num = num +1" +" where num > 100");
- retval will contain 0 if the operation succeeds, otherwise retval will contain the error code.
- retval will contain the number of rows updated.
- retval will contain the total of "num" after the update is complete.
- retval will contain the winning lottery number in the Michigan lottery.
A: retval will contain the number of rows updated.

- Code Fragment A
- Code Fragment B
- Code Fragment C
- Code Fragment D
A: Code Fragment D

Q: Assume you are working with the default JDBC characteristics of the Connection class and you issue the following command:
state.executeUpdate("delete from Data1");

Which of the following is true?
- The rows in your table will be deleted if you issue the following statement:
conn.commit();
- No rows are deleted because you didn't have a where clause on your delete statement.
- All of the rows in your table will be deleted.
- This is an illegal command, because we should have issued:
state.executeDelete(...) instead of executeUpdate
A: All of the rows in your table will be deleted.

Q: The ResultSetMetaData Interface is used for:
- Obtaining information about a ResultSet such as the number of columns, and the names of the columns in a ResultSet
- extracting Meta characters (non-ASCII characters) from the data that comes back from a query.
- Creating another ResultSet similar to the first ResultSet. JDBC defines the rules for transforming a ResultSet into a ResultSetMetaData class.
- If your ResultSet contains more than one row, you are required to first transform it into a ResultSetMetaData class before fetching the data.
A: Obtaining information about a ResultSet such as the number of columns, and the names of the columns in a ResultSet

Q: You have a column in your table which is an integer. In your ResultSet, you use the getString method to fetch the integer.
Which of the following statements is correct about fetching an integer with a getString method:
- The getString will successfully fetch an integer, but some overhead is incurred because the integer needs to be converted into a string.
- An Exception occurs when an integer is converted into a String.
- Your Compiler will detect that this is an illegal combination.
- JDBC will popup a dialog box asking if it's OK to convert your integer into a string.
A: The getString will successfully fetch an integer, but some overhead is incurred because the integer needs to be converted into a string.

Q: Which of the following is true about a JDBC PreparedStatements
- Once a Statement class has been used, it can then be converted to a PreparedStatement, because it has been properly initialized with its first execution.
- The President of the US has a Speech writer who creates a Prepared Statement that the President then delivers to the Nation.
- A PreparedStatement provides a template that can be validated one time and executed many times for SQL which fits the template characteristics.
- A PreparedStatement is a hunk of data stored in your database to simplify issuing SQL. Prefetching the PreparedStatement from the database speeds up future Database accesses.
A: A PreparedStatement provides a template that can be validated one time and executed many times for SQL which fits the template characteristics.

Q: If I want to have a Shopping Cart application and I want to use the jsp:useBean tag, I should use the scope value of:
- Don't specify scope because the default will be what you want
- session
- request
- application
A: session

Q: JSP stands for:
- Java Sounds Professional
- Java Sees Pages
- Java Server Pages
- Just Say Peace
A: Java Server Pages

Q: If you want to extract a value using a get method from your Java Bean, you should consider using the following tag:
- jsp:Extract
- jsp:getProperty
- jsp:getAttribute
- jsp:getValue
A: jsp:getProperty

Q: A characteristic that is NOT necessary for a Java Bean
- Must be a public class
- Should implement the JspBean Interface
- Should have no public instance variables
- Must have a zero-argument(empty) constructor
A: Should implement the JspBean Interface

Q: The Connection Pools in JDBC have the following characteristics:

Pick the item below which is NOT a valid characteristic:
- Connection pools keep a list of already logged in connections to a database.
- Connection pools can dynamically grow new Connections as more activity occurs in your application
- If you store your Connection pool as a JavaBean, you would want to use the Request scope
- If a Connection pool hits its maximum number of connections, a new request for connections can be suspended until a currently used Connection is freed up.
A: If you store your Connection pool as a JavaBean, you would want to use the Request scope

Q: Consider the following code:

Which of the following statements is TRUE
- These statements fetch configuration information from your html Form file.
- These statements can only be executed in a Servlet.
- These statements can only be executed in a JSP file
- The ServletContext object is available to every JSP and Servlet defined in a Tomcat Project.
A: The ServletContext object is available to every JSP and Servlet defined in a Tomcat Project.

Q: Which of the following is true:
- The above statements fetch the pageSize characteristic which is always available from the ServletContext.
- The above statements will generate an error, because the string "pageSize" should be "PageSize"
- The above statements will set pageSize = null, unless your application has previously issued a statement something like:
PageSize ps = new PageSize(.....);
config2.setAttribute("pageSize", ps);
- The getAttribute method doesn't exist for the ServletContext object. However, it does exist in an HttpSession.
A: The above statements will set pageSize = null, unless your application has previously issued a statement something like:
PageSize ps = new PageSize(.....);
config2.setAttribute("pageSize", ps);

- ContactSection.jsp will be loaded and compiled each time this page is hit.
- ContactSection.jsp will be compiled along with the containing jsp page the first time the containing page is accessed.
- The ContactSection.jsp file contains data that needs to be loaded each time this page is hit.
- The ContactSection.jsp file is a special file that JSP uses for storing the interactions between each of the JSP pages.
A: ContactSection.jsp will be compiled along with the containing jsp page the first time the containing page is accessed.

- The containing JSP page is informing the browser that it should fetch ShowFactors.jsp
- This command will set the Browser Forward button with the proper address.
- The containing JSP page is transferring control to a JSP page called ShowFactors.jsp.
- When a JSP page is pouting because it has just received an Exception, the jsp:forward command tells the JSP page how to get on with its life.
A: The containing JSP page is transferring control to a JSP page called ShowFactors.jsp.

- It is very inefficient to switch back and forth between Java mode and html mode.
- The above sequence won't execute properly because you can't switch back and forth within a single if statement.
- The class java.util.Calendar is not available to JSP pages because it doesn't implement the Cloneable interface.
- The above sequence of statements is hard to read and consequently it is hard to maintain this software.
A: The above sequence of statements is hard to read and consequently it is hard to maintain this software.

Q: In a JSP page, we have access to the 4 variables: pageContext, request, session, application.

For which of these 4 variables can you access the methods setAttribute, and getAttribute.
Click on ALL that Apply.
- application
- pageContext
- session
- request
A: application; pageContext; session; request

- application
- pageContext
- session
- request
- It will blow up with an exception because the variable "x" is not a proper Java bean.
A: pageContext

Q: If I have a lot of data to send from my form ( more than 2,000 bytes).  Which of the following forms should I choose :
- Form in line 1
- Form in line 2
- Form in line 3
- Form in line 4
- Form in line 5
- A form cannot send more than 2,000 bytes
A: Form in line 1

- doPost
- doGet
- Tomcat will automatically pick either doGet or doPost depending on the current load queue
A: doGet

Q: In the lecture on MVC from the Murach textbook, we had a program that looked like:

In line 21, there is a call to setAttribute to store information in the request object.
What kind of data can be stored with setAttribute?
- Classes that have proper set and get methods
- Classes that extend the Attribute abstract class
- String classes
- Primitives or any class
- any class
A: any class

Q: Where are cookies stored?
- On the server
- in web.xml
- On the client's browser
- in HTML
A: On the client's browser

- JSP Scriptlet A
- JSP Scriptlet B
- JSP Scriptlet C
- JSP Scriptlet D
A: JSP Scriptlet C

Q: This member function of the HttpServletResponse class is used to send a cookie back to the browser.
- addCookie
- sendCookie
- send
- addRequest
A: addCookie

Q: This method in the HttpSession class is used for saving information related to a specific session.
- storeAttribute
- setAttribute
- setResponse
- saveData
A: setAttribute

Q: This class contains all of methods needed for sending data back to a browser.
- Response
- HttpResponse
- SendHttp
- HttpServletResponse
A: HttpServletResponse

Q: This class contains data that is stored in a Client's browser.
- Cookie
- Session
- ClientInfo
- HttpInfo
A: Cookie

Q: This is a method in the HttpSession class that allows a web program to fetch data stored on the web server itself.
- getSession
- getAttribute
- getCookie
- getInitParameter
A: getAttribute

Q: By default, how many instances of a servlet are created by a Servlet Container?
- One per request
- One per session
- One
- None of the above
A: One

Q: This member function of the HttpServletRequest is used to obtain all of the cookies destined to a particular web page.
- getConfig
- cookiesFetch
- getCookies
- doGet
A: getCookies

Q: Many of the following lines will generate a JSP compile error.

Pick the line number which compiles properly.
- line 3
- line 4
- line 5
- line 6
A: line 6

Q: An instance of this class can be created for each user that connects to a given web site.
The created object can then be used to store information related to the specific user.
- Session
- HttpSession
- Cookie
- HttpCookie
A: HttpSession

Q: This object is passed in the doGet routine and contains information passed as input from the user's browser.
- HttpServletResponse
- HttpServletRequest
- HttpServletContext
- HttpGetData
A: HttpServletRequest

Q: This method in the ServletConfig class is used to fetch configurable information from the web.xml file.
- getInitParameter
- getParameter
- getInit
- getConfig
A: getInitParameter

Q: This method shows up in a JSP file that needs to do one time initialization before it starts fielding requests.
- init
- startJsp
- jspInit
- start
A: jspInit

Q: Which of the following  XML tags in a web.xml file contains a Servlet's Web address.
- http-address xml tag on line 1
- address xml tag on line 2
- web-url xml tag on line 3
- url-pattern xml tag on line 4
A: url-pattern xml tag on line 4

Q: This is the name of the Java Based Web server that we obtained from the Apache Organization
- Jakarta
- JavaServe
- J2EE
- Tomcat
A: Tomcat

Q: This html attribute tag is used inside of a Form to specify the URL location for the program that needs to process your Form.
- action
- url
- method
- doGet
A: action