Name: _________________________
Time allowed = 2 Hours. The number of marks allocated per question appears in parentheses: total = 53.
1.
(1) Concerning server resources, what is the biggest advantage of servlets when compared to CGI?
2.
3.
(2) Describe two of the services that a servlet engine provides to support the running of servlets.
4.
5.
6.
(1) Explain why (or why not) a servlet programmer is responsible for writing the code that creates the
HttpServletRequest and HttpServletResponse objects.
7.
8.
(2) Complete the following page directive so that it imports java.util.* and java.io.*
<%@ page language=java
9.
Name: _________________________
(2) When using a bean, we can use the setProperty tag from a JSP. What is the effect of the property="*" in <jsp:setProperty name="myBean" property="*" />
10. (2) We can include Java code in a JSP using either the code fragment tag <% %> or the
declaration tag <%! %>. What is the difference between these two approaches?
(Hint: think of where the code ends up in the generated servlet)
11. (1) One of the JSP page directives is errorPage. What happens when we use this directive?
12. (2) A Java bean must have a no-argument constructor. What other two requirements are there?
13. (2) a) What is an advantage of using cookies as compared to using hidden variables?
14. (1) When developing web applications, it can be difficult to test and debug Java code that is inside of JSP
or JSF pages. What should we do to improve this situation?
15. (2) The lecture notes describe four benefits of using JavaServer Faces. Describe two of them.
Name: _________________________
17. (2) With our JSP shopping cart, we used GetLoginData.jsp to retrieve the users login data and save it in the
Customer bean. Explain why we didnt need GetLoginData.jsp when we used JavaServer Faces.
18. (2) JavaServer Faces supports advanced navigation rules in its configuration file. Explain or give an example of this advanced navigation capability.
19. (1) When using a managed bean in JSF, how do we get initial values to be displayed on a form?
Name: _________________________
21. (2) With JDBC, if we have multiple statements that we want to group into a single transaction, what steps
should we take?
22. (2) Explain the purpose of the question marks in a PreparedStatement such as
PreparedStatement con.prepareStatement(
"update table1 set SALES = ? WHERE name LIKE ?");
23. (2) When using JDBC, there are two basic types of commands that we can use with a Statement object.
Describe the purpose of both of these.
Statement stmt = db.createStatement()
result1 = stmt.executeQuery(queryString);
result2 = stmt.executeUpdate(updateString);
Name: _________________________
26. (2) Briefly describe the Model-View-Controller design pattern that is used in Jakarta Struts.
27. (2) TCP sends data in numbered segments whereas UDP uses datagrams.
What are two advantages of TCP?
28. (1) Give an example of an application where it is better to use UDP rather than TCP.
29. (4) For our ChatServer, we used a thread for the GUI, a thread for the server loop, and a thread for each client. Explain why this was required.
30. (1) The constructor that we used for MulticastSocket is MulticastSocket(int port);
What is the purpose of the subsequent call to joinGroup(InetAddress addr)?