A client makes a request for information from a web-server. The web-server will then try to match this request with the appropriate response. An example of a typical response would be a HTML page. When the client receives the response, the client can then make another request which will trigger another response, thus forming a request-response cycle.
2. Explain how servlets facilitate processing of the request-response cycle.
Servlets expand the ability of the request-response cycle, by allowing for dynamic content to be included in responses. Since they are Java classes, they can be easily tailored to fit the domain in which they will be used.
3. How do you login to the Tomcat Manager?
If Tomcat is running, simply direct your web browser to the url http://localhost:8080/. Then click on the link: "Tomcat Manager" and type in the user id and corresponding password. If Tomcat is not running type in "startup" on the command line (assuming you have added the Tomcat bin folder to your path environment variable) and follow the above steps.
4. What is the Tomcat Manager used for in the StackStripes application?
The Tomcat Manager is used to deploy the StackStripes application.
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 will be the system name ("stackstripes" or "stackstripes-
6. How do you build a war directory structure in Ant? Where is this accomplished in the StackStripes application?
Using a build.xml file, you need to create an Ant task which extends a the Ant task used to create a jar file. The extension comes from the fact that you need to "WEB-INF" directory and all the subdirectories and files stored there. An example taken from the Ant Manual is shown below:

In the StackStripes application, this is accomplished in the "build.xml" file in the following manner:

7. How do you install a war directory in a running Tomcat server? What information does the Ant task need to accomplish this?
You simply copy the .war file and paste it into the $CATALINA.HOME/webapps directory. If you are using an Ant task to do this, then you simply set the location to copy the .war file to $CATLINA.HOME/webapps directory.
8. What is the "Model2" architecture? What are its advantages?
The Model2 or MVC (Model-View-Controller) architecture, is a software engineering design where the model or the data is separated from the user interface or view, in order for each to be unaffected by changes to the other. This is accomplished by adding a controller that handles the interaction between the model and the view.
9. What are JSP pages? How are they related to servlets?
A JSP page is a page that allows for both static and dynamic content to be generated on the same text-based page. The static content can be rendered in a number of formats including: HTML, WML, and XML. The dynamic content is generated using JSP elements.
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 a JSP handles a request for the first time, the JSP page must be translated and compiled into a servlet class. The servlet class is stored in the J2EE_HOME directory so that if JSP page is called on to handle another request, it does not have to be translated and compiled again.
11. What are JSTL tags? Why are they useful? What is an example JSTL tag from the StackStripes system?
JSTL are tag libraries that allow JSP pages to have functionality in areas such as basic scripting functions, XML processing, formatting, and database access. JSTL tags are useful because they are in XML format which allows for people who are not experienced with programming to use them more easily. An example of a JSTL tag from StackStripes is shown below:

12. What are Stripes tags? Why are they useful? What is an example Stripes tag from the StackStripes system?
Stripe tags link buttons and fields on a webpage to methods in the web applications java classes. The tags are useful because they easily link the webpage to the ActionBean class through the get/set methods and any handler methods. An
exammple of a Stripes tag from the StackStripes system is shown below:

This tag links the button called "Double It" to the method doubleIt in the StackActionBean class.
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 allows for a webpage to be accessed via programmable code rather than through a browser. HttpUnit is different from JUnit because it allows for webpages and web applications to be tested whereas JUnit only tests code. This is also why HttpUnit is useful. An example of HttpUnit from the StackStripes system is shown below:
WebForm pushForm = response.getFormWithID(pushFormParameter);
WebRequest pushRequest = pushForm.getRequest();
pushRequest.setParameter(numToPushParameter, "1");
response = conversation.getResponse(pushRequest);
This code pushes the number "1" onto the stack in the StackStripes web application.
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?
The "index.jsp" page had to be modified to add a button for the double it feature using the stripes tag for buttons. The StackActionBean and StackModel classes had to be modified to add the appropriate doubleIt methods. Nothing else had to be modified (the controller remained the same). Because of that, I learned that the MVC design pattern is flexible and allows for easy additions.
15. What are the equivalence classes that need to be tested for the Double It button?
Test the double it button on an empty stack, a small stack, and a large stack.
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?
The singleton design pattern states that there is only one instance of a class that is instantiated. An example of it in StackStripes is:
private static StackModel theInstance = new StackModel();
private ClearStack stack;
private StackModel() {
this.stack = new ClearStack();
}
It is needed so that everyone who is using the class is using the same instance of it.
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?
TestStackModel.java exercises code on the client side. TestStackActionBean exercises code on the server side. In order for Emma to report on the server side coverage, Tomcat 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:
Checks to make sure that tomcat is running.
tomcat.undeploy:
Undeploys/removes the web application from Tomcat.
compile:
Compiles all the code.
war:
Builds the war directory structure.
tomcat.deploy:
Deploys/adds the web application to Tomcat.
junit.tool:
Runs all JUnit tests.
junit.report:
Creates the HTML JUnit report.
junit:
Checks for JUnit errors and runs junit.tool and junit.report.
No comments:
Post a Comment