Thursday, November 1, 2007

Web App Questions

Overview:
This report will contain answers to the following questions.

Questions:

1. Explain in your own words the meaning of the web "request-response cycle".
The meaning of "request-response cycle" refers to a client and a server. Usually it is the client which does the "request" and the server which does the "response". The client will send various request to a server which the server will respond with various actions such as sending a html page. This is repeated over and over thus calling it a "cycle".


2. Explain how servlets facilitate processing of the request-response cycle.
Servlets are java code usually in a server application that can process request and respond to that request which will depend on the request itself.


3. How do you login to the Tomcat Manager?
First run the server from the command line. Then open the web http://localhost:8080/ from a browser. Click on the Tomcat Manager link and then enter the username: "admin" and password "changethis".


4. What is the Tomcat Manager used for in the StackStripes application?
The tomcat manager is used so that our StackStripes application can be executed in a web browser by allowing the program to run through an application server such as tomcat.


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 in which the StackStripes reside in, is first located where the apache-tomcat folder is located. Within this folder will contain another folder called "Webapps" which will contain the stackstrips application. Within the stackstripes folder contains more files such as a "META-INF" AND "WEB-INF" folders, and jsp files.


6. How do you build a war directory structure in Ant? Where is this accomplished in the StackStripes application?
To build a war directory structure in ant, a target must be created within the build.xml file. Within this target, certain tags are necessary in order to process where the war file will be placed and which files are to be copied into the archieve.

7. How do you install a war directory in a running Tomcat server? What information does the Ant task need to accomplish this?
This can be done exactly the same way as we installed the example war file into stripes. A war file must be copied into the "webapps" folder where tomcat will automatically install the war directory.

8. What is the "Model2" architecture? What are its advantages?
The Model2 architecture consist of a "model" which is the actual content that is stored in databases or xml files. It also consist of a "view" which is the html page and finally consist of a "controller" which is program code that dynamically gathers data and generates the content within the html.


9. What are JSP pages? How are they related to servlets?
A JSP page is a text-based document that has 2 types of text. One type is static template data such as HTML and XML data. The other type is JSP elements which constructs dynamic content. JSP pages are related to servlets by means that a JSP page services requests as a servlet.


10. Why is there a delay when retrieving a JSP page for the first time? Where is the Java code for that page stored?
When ever a JSP page service a request, it must turn into a servlet. The servlet is stored in a J2EE_HOME directory. If the JSP page runs again, it does not have to be turned into a servlet since the servlet is already stored thus saving us time. The java code is stored within the page itself.


11. What are JSTL tags? Why are they useful? What is an example JSTL tag from the StackStripes system?
JSTL tags is part of a tag library that encapsulates core functionality commonly needed when writing dynamic JSP pages. JSTL tags are useful that they allow embedded java code to look nicer within scriplet tags. Without JSTL tags, java code cannot cannot be reused by other JSP pages and retrieving objects our of the http request and session is cumbersome. A example of a JSTL tag from the stack stripes is the "for each" tag which allows looping.


12. What are Stripes tags? Why are they useful? What is an example Stripes tag from the StackStripes system?
Stripes tags are tags that link web page buttons to java bean like "get" and "set" methods. They are useful because they use the same name as the method's name. An example of a stripes tag is which is from the index.jsp file.


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 is a tool that can be used to represent a web page using program like code. HttpUnit is different from using Junit because HttpUnit will actually use the actual web page that is from a server. HttpUnit is useful because we can write code to do actual user interactions with a web page in a simple manner. A example of a HttpUnit is:

pushForm = response.getFormWithID("PushForm");
pushRequest = pushForm.getRequest();
pushRequest.setParameter("numToPush", "2");
response = conversation.getResponse(pushRequest);


which will actually perform a click on the "PushForm" button on the webpage.


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?
In order to implement a "double it" button, the JSP page had to be modified to include another button and a additional method had to be created to implement the double it function. The way that the two parts communicated did not need to change. I learned that the MVC design pattern can allow changes to the JSP pages relatively easy.


15. What are the equivalence classes that need to be tested for the Double It button?
To completely test the "double it' button, it needs to be tested with a empty stack, 1 element or a large number of 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.





Before:



After:
















17. What is the singleton design pattern? What is an example of its use in StackStripes? Why is it needed?
A singleton design pattern refers that only 1 instance of the class can be created. An example of a singleton design pattern that is located in the stackstripes application consist of the following lines of code:

private static StackModel theInstance = new StackModel();

private ClearStack stack;

private StackModel() {
this.stack = new ClearStack();
}

This will allow each client that access and minipulate the same stack.

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?
The "TestStackActionBean.java" file test the code on the server side since it uses HttpUnit. The "TestStackModel.java" file test the code for the client side. In order for emma to correctly report the coverage on the server side, the tomcat applicatio must be shutdown first.

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 -makes sure that the tomcat application is running.

tomcat.undeploy - removes the stackstripes from the server.

compile - compiles the code

war - packages the web files into a WAR file.

tomcat.deploy - add the stackstripes war file onto the tomcat server.

junit.tool - runs the junit tests.

junit.report - creates a report in html format that can be viewed in a browser.

junit - makes sure that the junit test and report runs successfully first.

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?

I have no experience with any other frame works.

No comments: