Course: Intro to Scripting Language: Python (APT TEMPLATE)

Q: An HTTP response
- is sent from the web server to the client
- is sent from the client to the web server
- is sent from the servlet engine to the client
- is sent from the client to the servlet engine
A: is sent from the web server to the client

Q: To minimize the amount of Java code in a JSP, you
- use HTML pages to perform the business logic
- use HTML pages to act as the user interface
- use servlets to handle the processing requirements
- use servlets to act as the user interface
A: use servlets to handle the processing requirements

Q: When a JSP is requested for the first time, the JSP
- calls the servlet that it is associated with
- calls the built-in request object
- is converted into a servlet
- is converted into HTML
A: is converted into a servlet

Q: If you’re developing Java web applications on a Local Area Network, each developer’s computer needs these items installed on it:
- Just the Java JDK
- Java JDK and Java EE JAR files
- Java JDK, Java EE JAR files, and web server software
- Java EE JAR files and web server software
A: Java JDK and Java EE JAR files

Q: The best way to develop Java web applications is to use an Integrated Development Environment such as:
- NetBeans or Eclipse
- Foxfire or Netscape
- FileZilla or CuteFTP
- Tomcat or Apache
A: NetBeans or Eclipse

Q: The Title tag in an HTML document specifies the title
- that’s used to refer to the document
- that’s used to refer to the application
- that’s displayed in the title bar of the browser
- that’s displayed at the start of the web page
A: that’s displayed in the title bar of the browser

Q: Which of the following is a valid HTML comment?
- <b><span style="font-family:'Courier New'"><span style="font-size:9pt">// comment</span></span></b>
- <b><span style="font-family:'Courier New'"><span style="font-size:9pt"><!--comment --></span></span></b>
- <b><span style="font-family:'Courier New'"><span style="font-size:9pt"><%-- comment --></span></span></b>
- <b><span style="font-family:'Courier New'"><span style="font-size:9pt"></comment></span></span></b>
A: <b><span style="font-family:'Courier New'"><span style="font-size:9pt"><!--comment --></span></span></b>

Q: The Anchor tag that follows will go to which directory?<br><b><span style="font-family:'Courier New'"><span style="font-size:9pt"><a href="/troubleShooting">Trouble Shooting</a></span></span></b>
- the troubleShooting directory that’s subordinate to the current directory
- the troubleShooting directory that’s in the webapps directory
- the troubleShooting directory that’s one level up from the current directory
A: the troubleShooting directory that’s in the webapps directory

Q: The Anchor tag that follows<br><b><span style="font-family:'Courier New'"><span style="font-size:9pt"><a href="update.jsp">Update</a></span></span></b>
- displays Update as a hyperlink
- displays update.jsp as hyperlink
- displays Update as plain text
- displays update.jsp as plain text
- displays nothing
A: displays Update as a hyperlink

Q: An HTML form can be used to pass data to
- another HTML page
- a servlet
- a JSP
- a JSP or a servlet
A: a JSP or a servlet

Q: What happens when the button in the following form is clicked?<br><b><span style="font-family:'Courier New'"><span style="font-size:9pt"><form action="grades.jsp" method="get"><br>    ID: <input type="text" name="studentID"><br><br>    <input type="submit" value="Get My Grades"><br></span></span></b><b><span style="font-family:'Courier New'"><span style="font-size:9pt"></form></span></span></b>
- the data in the studentID text box is passed to the get method
- the user is prompted to enter a student ID
- the data in the studentID text box is passed to the grades.jsp file
- the grades.jsp file is requested, but no data is passed
A: the data in the studentID text box is passed to the grades.jsp file

Q: How many radio buttons from the following code can be selected at any given time?<br><b><span style="font-family:'Courier New'"><span style="font-size:9pt"><input type="radio" name="address" value="Home">Home Address<br><input type="radio" name="delivery" value="FedEx">Federal Express <br></span></span></b><b><span style="font-family:'Courier New'"><span style="font-size:9pt"><input type="radio" name="delivery" value="UPS">UPS</span></span></b>
- 0
- 1
- 2
- 3
A: 2

Q: The tabindex attributes of the controls on a form determine
- the sequence in which they appear on the form
- the index values that can be used to refer to the controls
- the sequence in which they will be passed to the related JSP
- the sequence in which they will receive the focus when the Tab key is pressed
A: the sequence in which they will receive the focus when the Tab key is pressed

Q: A JSP expression can contain any Java expression that evaluates to a
- String object
- Java object
- primitive type
- primitive type or Java object
A: primitive type or Java object

Q: Which of the following JSP expressions is valid?
- <b><span style="font-family:'Courier New'"><span style="font-size:9pt"><%= request.getParameter("occupation"); %></span></span></b>
- <b><span style="font-family:'Courier New'"><span style="font-size:9pt"><%= request.getParameter("occupation") %></span></span></b>
- <b><span style="font-family:'Courier New'"><span style="font-size:9pt"><%= String occupation = request.getParameter("occupation"); %></span></span></b>
- <b><span style="font-family:'Courier New'"><span style="font-size:9pt"><%= String occupation = request.getParameter("occupation") %></span></span></b>
- None of the above
A: <b><span style="font-family:'Courier New'"><span style="font-size:9pt"><%= request.getParameter("occupation") %></span></span></b>

Q: The following code<br><b><span style="font-family:'Courier New'"><span style="font-size:9pt"><%<br>    String[] mailTypes = request.getParameterValues("mail");<br></span></span></b><b><span style="font-family:'Courier New'"><span style="font-size:9pt">%></span></span></b>
- returns the name of all request parameters from the mail.jsp page
- returns the first value of the mail parameter or null if none exist
- returns all values of the mail parameter or null if none exist
- returns the values of all request parameters from the mail.jsp page
- is invalid
A: returns all values of the mail parameter or null if none exist

Q: In general, you should use the Post method instead of the Get method when
- the request writes data to the server
- the request reads data from the server
- you want users to be able to include parameters in their bookmarks
- when you’re transferring 4 KB or less of data
A: the request writes data to the server

Q: To use your own Java class in a JSP, you can import the class with a
- JSP scriptlet
- JSP expression
- JSP directive
- JSP declaration
A: JSP directive

Q: Which of the following is a valid JSP comment?
- <b><span style="font-family:'Courier New'"><span style="font-size:9pt">// comment</span></span></b>
- <b><span style="font-family:'Courier New'"><span style="font-size:9pt"><!--comment --></span></span></b>
- <b><span style="font-family:'Courier New'"><span style="font-size:9pt"><%-- comment --%></span></span></b>
- <b><span style="font-family:'Courier New'"><span style="font-size:9pt"></comment></span></span></b>
A: <b><span style="font-family:'Courier New'"><span style="font-size:9pt"><%-- comment --%></span></span></b>

Q: In the code that follows, the numOfErrors variable<br><b><span style="font-family:'Courier New'"><span style="font-size:9pt"><%! int numOfErrors = 1; %></span></span></b>
- is initialized each time the page is requested
- is an instance variable that is not thread-safe
- is ignored by the JSP engine
- is invalid JSP code
A: is an instance variable that is not thread-safe

Q: When a JSP is requested for the first time, the JSP engine does all but one of the following. Which one is it?
- generates a servlet for the JSP
- generates the HTML code for the JSP
- creates one instance of the servlet class
- creates one thread
A: generates the HTML code for the JSP

Q: When a JSP is requested for the second time, the JSP engine
- creates a thread that has its own copy of the instance variables
- creates a thread that has its own copy of the local variables
- creates an instance of the JSP that has its own copy of the instance variables
- creates an instance of the JSP that has its own copy of the local variables
A: creates a thread that has its own copy of the local variables

Q: A session object is created
- every time a browser makes a request for a web page
- every time a browser requests a servlet
- every time a browser requests a jsp
- the first time a browser requests a servlet or JSP from a web site
A: the first time a browser requests a servlet or JSP from a web site

Q: The current session object is available
- only to JSPs
- only to servlets
- to both servlets and JSPs
A: to both servlets and JSPs

Q: Which of the following statements is invalid?
- <b><span style="font-family:'Courier New'"><span style="font-size:9pt">String name = session.getAttribute("fullName");</span></span></b>
- <b><span style="font-family:'Courier New'"><span style="font-size:9pt">Book book = (Book) session.getAttribute("bookObj");</span></span></b>
- <b><span style="font-family:'Courier New'"><span style="font-size:9pt">session.setAttribute("fullName", "Ted Andrews");</span></span></b>
- <b><span style="font-family:'Courier New'"><span style="font-size:9pt">session.removeAttribute("fullName");</span></span></b>
A: <b><span style="font-family:'Courier New'"><span style="font-size:9pt">String name = session.getAttribute("fullName");</span></span></b>

Q: When you use URL encoding for session tracking, you must
- convert all HTML pages in the application to JSPs
- use the encodeURL method to encode all URLs in the JSPs
- use the encodeURL method to encode all URLs in the servlets
- a and b above
- a, b, and c above
A: a and b above

Q: Persistent cookies
- are removed after the session ends
- exist after the session ends
- can’t be deleted
- are often called hidden fields
A: exist after the session ends

Q: After the code:
mediaCookie.setPath("/");
The cookie named mediaCookie can be accessed by
- only the current directory
- the entire web application
- the entire web server
- anyone
A: the entire web application

Q: The following Anchor tag demonstrates how to use<br><b><span style="font-family:'Courier New'"><span style="font-size:9pt"><a href="/WorkServlet?shift=<%= shiftCode %>" ><br>   View your schedule<br></span></span></b><b><span style="font-family:'Courier New'"><span style="font-size:9pt"></a></span></span></b>
- URL rewriting
- URL encoding
- hidden fields
- cookies
A: URL rewriting

Q: 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?
- the parameters aren’t shown in the URL
- the user can see the parameters by using the browser to look at the page’s source code
- you don’t have to store the parameters in the session object
- you can’t use URL encoding
A: you can’t use URL encoding