Talk:CSC667 final

Question 1: Explain the terms below
(a) Cookie (explain what it is and how to use, with HTTP syntax)

(b) Session (explain what it is and how it is implemented)

(c) If cookie is disabled from the client’s browser, what are the possible options to do the session tracking?

2. Servlet and JSP
(a) What are the advantages of using Servlet/JSP over conventional CGI programming? (list at least 3)

(b) What are the differences between Servlet and JSP? (When is servlet preferred and when is JSP perferred)

(c) Explain the life cycle of a JSP page in terms of translation, compilation, loading and execution in case of the first time access and the second access.

(d) Explain procedures to create your own MyServlet (a simple servlet that receives your name and generate a response that says a greeting to you) using the HttpServlet class.

3. Session tracking using Servlet or JSP
(a) How to create a Session in Servlet? (Show an example using actual codes.)

(b) How to store information (shopping cart – ordered items) into the session and retrieve back? When explicit casting is used and why?

(c) What happens if session expires or a client kills the browser? What can you do to prevent possible loss of information?

4. Write comments where (a) – (f) is marked about the bold-faced code
<%@ page language="java" import="com.wrox.projsp.ch05.*, java.util.*" errorPage="error.jsp" %> // (a)

 

 // (b)

 <% String display = "showLogin.html"; User user = loginBean.authenticate; if (user != null) { user.setIpAddr(request.getRemoteHost); session.setAttribute("user", user); // (c) //

monitor.put(user, session); System.out.println("Assigned new session for: " + user); session.setMaxInactiveInterval(900); display = "browse.jsp"; } %> "/> // (d)

5. Write comments like in question No.4
<%@ page import="com.wrox.projsp.ch05.*" errorPage="error.jsp" %> Process the Order <% if(session.getValue("user") == null) { response.sendRedirect("showLogin.html"); } // (a)

User user = (User)session.getValue("user"); // (b)

String display = "showDetails.jsp"; int mode = (new Integer(request.getParameter("action"))).intValue; System.out.println("Action" + mode); Order order = null; switch(mode) { /* 0 = add / modify 1 = complete 2 = clear 3 = display case(0): case(2): String itemIds[] = request.getParameterValues("itemId"); // (c)

If (itemIds != null && itemIds.length != 0) { order = new Order(user); order.setItemIds(itemIds); session.setAttribute("anOrder", order); // (d)

} else session.removeAttribute("anOrder"); break; case(1): // Complete the order here order = (Order)session.getAttribute("anOrder"); System.out.println("Order: " + order); order.complete((Catalog)pageContext.getAttribute("catalog", pageContext.APPLICATION_SCOPE)); display = "receipt.html"; break; } response.sendRedirect(display); // (e)

%> 	(f) Explain about the scope (page, request, session, application) of java beans in JSP

(g) List and explain about the implicit objects (provided without explicit declaration) in JSP.

(h) Explain directory structure for tomcap web applications – Where is the application home directory placed, where html/jsp, java bean or servlet classes are stored?

(i) What is war file and used for?

6. XML
(a) Explain what is validity and well-formness rules in XML.

(b) What are the advantages of using XML (list 3)

(c) Explain the difference of DOM and SAX parser

(d) Generate one well-formed and valid XML file from the given DTD. It should contain at least 10 elements and 1 attribute to make sure you understand DTD.

<!ELEMENT SONG (TITLE, COMPOSER+, PRODUCER*, PUBLISHER*, LENGTH?, YEAR?, ARTIST+)> <!ELEMENT TITLE (#PCDATA)> <!ELEMENT COMPOSER (#PCDATA)>

<!ELEMENT PRODUCER (#PCDATA)> <!ELEMENT PUBLISHER (#PCDATA)> <!ELEMENT YEAR (#PCDATA)> <!ELEMENT ARTIST (#PCDATA)> <!ATTLIST SONG LENGTH CDATA #IMPLIED>

(e) Explain how xml file is displayed on the browser ([i]by itself, [ii]with stylesheet, [iii]with applet or plug in)

(f) List two major advantages of XML over HTML and explain about reason for each advantage. (f) What is XSLT? How XSLT is used with XML?

(h) What would be results of executing XSLT below with hyper link connection to a given xml file?

 

7. With a given DTD, make an example of VALID XML file. (You may start with the root element excluding processing instructions)
<!ELEMENT planner ( year* )>

<!ELEMENT year ( date+ )>

<!ATTLIST year value CDATA #REQUIRED>

<!ELEMENT date ( note+ )>

<!ATTLIST date month CDATA #REQUIRED>

<!ATTLIST date day CDATA #REQUIRED>

<!ELEMENT note ( subject & contents )>

<!ELEMENT subject ( #PCDATA )>

<!ELEMENT contents ( #PCDATA )>

<!ATTLIST note time CDATA #IMPLIED>

. Explain the difference of DOM parser and SAX parser.
Show one Java sentence that invokes builder.parse method when requesting actual parsing in both parser cases in terms of return value and its parameters.

And explain shortly how they are handled in different way. (which one is event driven?)

Question 9
Which parser is more efficient when making a Web Browser? Why?

In what kind of applications is the other parser more efficient?

10. With a given XML file, show a DOM structure returned by DOM parser.
ABCCDEAbout tomorrow

 Hello Test

Question 11-- Synchronize
For what the "synchronized" keyword is used and show how they are used in java code?

When/why do you have to care about the synchronization in the e-commerce applications?

Question 12- Java Applets
Explain why Java Applets have more security issues than Java Applications and what are the examples of those security related restrictions for Applets?

In addition to those security issues, what are the limitations that applet has? (list one)

Question 13 JDBC
Explain about JDBC – how is it used in e-commerce and what is the advantage of using JDBC?

Question 14 Connection Pool
What is connection pool? How/why does it improve overall performance?

Question 15: prepared statements
How does prepared statement improve the performance of e-commerce applications? (Show using an example code)