Monday, November 5, 2007

25.WebAppQuestions

1.Explain in your own words the meaning of the web "request-response cycle".
The "request-response cycle" refers to a cycle of data-retrieval between a server and a client. The client, usually a user, would send out a request to the server. The server would then try to match the request to produce a response, usually a webpage. The client might send out another request after retrieving the information from the response and the cycle goes on.

2.Explain how servlets facilitate processing of the request-response cycle.
Servlets facilitates the process by allowing user to send in request and then produce dynamic response displayed on a webpage.

3.How do you login to the Tomcat Manager?
Make sure Tomcat is running by invoking "catalina run". Go to http://localhost:8080 and the tomcat page should show up. Click onto the link "Tomcat Manager" and log in with the pre-set username and password.

4.What is the Tomcat Manager used for in the StackStripes application?
It is used for deploying StackStripes.

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!)
The directory is named StackStripes in the Tomcat's webapps folder. There are the 2 .jsp files and two subdirectory named META-INF and WEB-INF. META-INF contains meta data whereas WEB-INF contains java classes.

6.How do you build a war directory structure in Ant? Where is this accomplished in the StackStripes application?
A war directory structure can be created by defining a task that specify the target war file to build, the web.xml and the destination of that war file.
In StackStripes, this is accomplished in the build.xml.

7.How do you install a war directory in a running Tomcat server? What information does the Ant task need to accomplish this?
If Tomcat is running, we can just copy and paste the .war file into the Tomcat's webapps folder. To do so with an Ant task, create a task as described in the previous question.


8.What is the "Model2" architecture? What are its advantages?
Model2 uses the Model-View-Controller design pattern which separate data (model) and user interface (view) concerns by a controller. The advantage is that changes made to the user interface will not affect data handling and vice versa.

9.What are JSP pages? How are they related to servlets?
They are pages that contain java script which provides dynamic response to a web client request. They are compiled into a servlets by a JSP compiler.

10.Why is there a delay when retrieving a JSP page for the first time? Where is the Java code for that page stored?
This is because a JSP page has to be compiled into a servlet. Once it is compiled, it is stored into the servlet and allows quick retrieval of the page. The Java code is stored inside the page.

11.What are JSTL tags? Why are they useful? What is an example JSTL tag from the StackStripes system?
JSTL tags provide most functionality needed in a JSP page. They are useful because they are in XML format and so are convenient to use.

An example is found in index.jsp:
< 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?
They are tags that start with "strips:" and they are very useful becuase they link up the Java classes and the JSP pages.

An example is found in index.jsp:
< 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?
HttpUnit tests the code by simulating browsing a site whereas JUnit can only tests Java code and cannot simulate browser behavior.

An example is found in TestStackActionBean.java:
WebRequest pushRequest = pushForm.getRequest();
pushRequest.setParameter("numToPush", "1");
response = conversation.getResponse(pushRequest);

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 method to implement doubling a stack is added and index.jsp is modified to define the button
that execute the method. From this, I learned that the controller need not be modified.

15.What are the equivalence classes that need to be tested for the Double It button?
The equivalence classes includes doubling an empty stack, doubling a normal stack and doubling a stack with a lot of items.

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.
Before:


After:


17.What is the singleton design pattern? What is an example of its use in StackStripes? Why is it needed?
It is a design pattern used to restrict instantiation of a class to only one object.

An example is found in StackModel.java:
private static StackModel theInstance = new StackModel();

This is needed to ensure the user is only dealing with the same stack all the time.

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?
TestStackActionBean.java tests on the server side by using HttpUnit and JUnit while TestStackModel.java tests on the client side using JUnit. Emma shuts down Tomcat in order to get the coverage on server side testing.

19.Running 'ant -f junit.build.xml' results in the following target invocations: tomcat.check, tomcat.undeploy, compile, war, tomcat.deploy, junit.tool, junit.report, junit. Explain what each of these targets do.
tomcat.check: Check to see if Tomcat is running
tomcat.undeploy: Undeploy the application from Tomcat if it exists
compile: compile the source code
war: generate the war directory
tomcat.deploy: deploy the application onto Tomcat
junit.tool: runs junit tests over the source code
junit.report: genearte html report on junit tests result
junit: to run junit.tool and junit.report

20.(Optional) If you have experience using one or more other web application frameworks, discuss your initial reactions to Stripes. How is it similar, or different, or better, or worse than your previous experience?
Tomcat is the only web application frameworks I have worked with so far.

No comments: