Saturday, November 3, 2007


1. Explain in your own words the meaning of the web "request-response cycle".
A: User request a page by clicking or some other means. The brower prepare the request and send it to the server, then receive the response from server and show in to the user.

2. Explain how servlets facilitate processing of the request-response cycle.
A: Servlets are able to generate page dynamically, so that the server can return much more different pages accordingly, without storing them beforehand.

3. How do you login to the Tomcat Manager?
A: I access my Tomcat page from http://localhost:8080/, then click the Tomcat Manager on the left to login, with username and password.

4. What is the Tomcat Manager used for in the StackStripes application?
A: Through Tomcat Manager, we are able to deploy our StackStripes without stopping the server.

5. What is the directory and file layout of an installed web application like StackStripes? (This is NOT the same as the directory and file layout of the StackStripes distribution!)
A: the web applications are installed in $CATALINA_HOME/webapps. Inside each application's directory, there is a directory called WEB-INF, where stored the code of the application.

6. How do you build a war directory structure in Ant? Where is this accomplished in the StackStripes application?
A: We build it using war task in an Ant target. It is done in build.xml, in the target "war".

7. How do you install a war directory in a running Tomcat server? What information does the Ant task need to accomplish this?
A: By getting this page: http://localhost:8080/manager/deploy, with argument path and war.
Ant need the host's address, the system name to generate the path, and the war file's location.

8. What is the "Model2" architecture? What are its advantages?
A: MVC contains 3 part: Model, which run web application, access database and generate the response page; View: whatever you see in your browser; Control: connector between Model and View, process user's request from view, interact with Model, and return the page to be shown next.
Its advantage is separated program logic from user view, so that it is much easier to modify and maintain the web application.

9. What are JSP pages? How are they related to servlets?
A: JSP is a page that contain static text data such as HTML, and dynamic content such as scriptlets or stripes elements. It can generate the proper page according to user's interaction. JSP will be compiled into servlet when first time it is requested, and recompile later when needed.

10. Why is there a delay when retrieving a JSP page for the first time? Where is the Java code for that page stored?
A: Because JSP will be compile into servlet for the first time retrieving. The Java code is stored in server.

11. What are JSTL tags? Why are they useful? What is an example JSTL tag from the StackStripes system?
A: JSTL tags are a kind of xml tag in HTML to implement some kinds of functionalities. They are useful because of their simplicity, which enables people other than Java programmers to modify the code. Example JSTL tags in StackStripes system are:

< c:foreach var="element" items="${actionBean.stackIterator}">

12. What are Stripes tags? Why are they useful? What is an example Stripes tag from the StackStripes system?
A: Stripes tags are tags that present functional framework that defined by Stripes. With Stripes tags, we are able to separate the Java control codes from JSP pages. All Java codes can be put in Java classes and called by Stripes tags.
Example Stripes tags in StackStripes system include:

< stripes:form id="PushForm" action="/Stack.action">
< stripes:select size="1" name="numToPush">
< stripes:option value="1">1
< stripes:submit value="push" name="push">

13. What is HttpUnit? How is it different from JUnit? Why is it useful? What is an example use of HttpUnit from the StackStripes system?
A: HttpUnit is a testing framework that emulates behavior of browser to test the function of web sites or web applications. Unlike JUnit which is a unit testing framework for all java programs, HttpUnit is focus in testing web applications. It makes it possible to verify web applications or web sites by automated testing.
An example in StackStripes system is :

WebConversation conversation = new WebConversation();
String Url = testHost + "stackstripes";
WebResponse response = conversation.getResponse(Url);
assertEquals("Checking index.jsp retrieval", pageTitle, response.getTitle());

which check if the page is retrieved correctly.

14. What needed to be changed in order to implement the Double It button? What didn't need to be changed? What did you learn about the MVC design pattern from this exercise?
A: I need to add a stripes:form for the Double It button, and all other things remain unchanged. MVC is very facilitated to use, as simple as to add a method in a class.

15. What are the equivalence classes that need to be tested for the Double It button?
A: empty stack and stack with some elements.

16. Provide two screen images of your new StackStripes application with the Double It button, one showing the page before and one showing the page after hitting the "Double It" button.
A: before:


17. What is the singleton design pattern? What is an example of its use in StackStripes? Why is it needed?
A: singleton design pattern is a design pattern that ensure there is only one object of the class in runtime. In StackStripes, a static instance is defined, And the construction method is private so that users can not call it to create a new instance. Also, there is a getInstance method serve as the function as constructor, which always return this static singleton instance.
We use it because we need to ensure that users are interacting with the same instance wherever the open the page.

18. Some of the StackStripes tests exercise code on the "server side", while others exercise code on the "client" side. Which test classes exercise code on the "server", and which exercise code on the "client"? How does Emma deal with this to create appropriate coverage data?
A: Tests in TestStackModel exercise codes on the "client" side, and tests in TestStackActionBean exercise codes on the "server side". Emma track the running code in server side and put those data in However, emma has to stop the server to make that file finalized onto disk so that it can be read to create appropriate coverage data.

19. Running 'ant -f' results in the following target invocations: tomcat.check, tomcat.undeploy, compile, war, tomcat.deploy, junit.tool,, junit. Explain what each of these targets do.
A: First, tomcat.check target checks if tomcat is running and can be access properly. Then, tomcat.undeploy target undeploys the existed web application in the server. After that, compile target compiles the java codes and war target packs all web files into a war package. Then tomcat.deploy target is called to unwar the war package and deploy the web application onto server. After deploying, junit target awoke junit.tool and targets to run the unit tests in the web application and generate an HTML report of the JUnit tests.

No comments: