1. Explain in your own words the meaning of the web "request-response cycle".
A Web request-response cycle consists of the client's software i.e a Web browser sending requests to the Web server and the servers sending a response. This is a cycle known as the HTTP request/response protocol. The server can accept, process, and return the requested information to the client.
2. Explain how servlets facilitate processing of the request-response cycle.
Servlets are implemented in the Java programming language that run inside a web application server. It handles low level details of the HTML protocol, then it facilitates the request/response cycle by allowing developers to write Java code to handle user request. It also gives an object orient interface.
3. How do you login to the Tomcat Manager?
First of all to access the Tomcat manager one must first add a new username and password and associate the role manger. This must be done in the user.xml file. Then you go to this URL the http://localhost:[and the port], where you can login with the set username and password in the user.xml file.
4. What is the Tomcat Manager used for in the StackStripes application?
The Tomcat Manager is used in the StackStripes application for conviniently executing manager commands with Ant. Specifically, in the StackStripes application we use the deploy and undeploy tasks.
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 Web module structure contains an assembly root directory that has JSP pages, static HTML pages, and applet classes and a WEB-INF subdirectory. The WEB-INF directory contains files such as web.xml, sun-web.xml, and *.tld. It has the lib, classes, and tags as its subdirectories. The lib directory contains all library archive files. The classes directory contains all server-side .class files for the instance of the current web module, and the tags directory contains all .tag files.
6. How do you build a war directory structure in Ant? Where is this accomplished in the StackStripes application?
To build a WAR file under Ant you must specify the dest webxml and destfile targets. In the StackStripe application this is done in the build.xml file with the war target.
7. How do you install a war directory in a running Tomcat server? What information does the Ant task need to accomplish this?
You can use the Tomcat server's deploy tool, the asAnt creat-war, or just simply copy the war file into the Webapps directory since it will find and install any war files which reside in that directory. The Ant task needs to know where the WebBass directory resides.
8. What is the "Model2" architecture? What are its advantages?
Model 2 architecture uses Model-View-Controller design pattern to separate presentation from content. The controller's job is to pass the request to the right view (JSP), which in turn invokes the JavaBean which then may access a database.
The advantages of Model2 architecture is that it brings the "write once, run anywhere" paradigm to interactive Web pages, it is also fairly simple to learn and wield Java as a server-side scripting language. However the biggest advantage is that it helps effectively separate presentation from content.
9. What are JSP pages? How are they related to servlets?
JSP (Java Server Pages) is a language that allows easy creation of web content that contain both static and dynamic components. JSP are text based documents that contain implementation of how to process a request and construct a response. They also are extensions to servlets. When a request to a JSP is made, it looks if the the JSP pages's servlet is older than the JSP page itself. If this is the case it will translate the JSP page into a servlet class. The advantage is that the compilation is automated.
10. Why is there a delay when retrieving a JSP page for the first time? Where is the Java code for that page stored?
The delay occurs because the JSP page must be translated, compiled, and checked for errors when loaded the first time. I could not find any information on where the Java code is stored but I assume it is stored on the server side.
11. What are JSTL tags? Why are they useful? What is an example JSTL tag from the StackStripes system?
JSTL contains sets of standard tag libraries that give the required functionality which are needed when writing dynamic JSP pages. They are useful because they fix the shortcomings of JSP scriptlet tags. A JSTL tag used in StackStripes is for each.
12. What are Stripes tags? Why are they useful? What is an example Stripes tag from the StackStripes system?
Stipes tags are tags defined in the standard tag library and a dynamic attribute tag library. They are useful because they give easy implementation for comunication between the Web page and the Java code. Example Stripes tag:
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?
Programmers can use HttpUnit to imitate a real mouse click on a Web link. Therefore, it is crucial for writing test cases for programs with Web applications, whereas JUnit can only test the client site program. An example from the StackStripes is: WebConversation conversation = new WebConversation();
// Get welcome.jsp page and check for successful retrieval
String Url = testHost + "stackstripes";
WebResponse response = conversation.getResponse(Url);
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 the Double It button the index.jsp needed to include a submit tag with the name doubleIt and value Double It. The stackModel class needed a new doubleIt method and the StackActionBean class needed a new doubleIt Resolution method. No other methods or code needed to be changed. This exercise nicely illustrates the MVC design. By doing this exercise I learned how it all works.
15. What are the equivalence classes that need to be tested for the Double It button?
From a black box perspective it is good to test for the empty stack, stack with one item, average items, and many items. But since we only need to make sure that the doubleing works, it should be sufficient to push an item onto the stack and then simulate the double it click and check that the items doubled.
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 hitting Double It:
After hitting Double It:
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 supported by the static keyword. This allows working only on one object. Therefore, no other class or method can make a copy of that object, but rather access it directly via getting an instance of it. I think this is needed because we have to make sure, with the synchronized keyword, that we change only one object at the same time. An example is:
private static StackModel theInstance = new StackModel();
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 server side tests are in StackActionBean whereas the client side test are in StackModel. Emma gathers the needed data when from the Tomcat server and creates the appropriate coverage. However, the coverage is not available until the Tomcat server is shut down.
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.ckeck, makes sure that the server is running and that we have access to it.
tomcat.undeploy, removes stackStripes from the Tomcat server.
compile, compiles the code.
war, builds the directory structure need for tomcat deployment.
tomcat.deploy, deploys the war directory into Tomcat server.
junit.tool, execute junit test on the server and client side.
junit.report, creates a HTML junit reprot.
junit, runs junit.tool, junit.report and shows errors as encountered.
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 only created Web sites using basic HTML and Notepad, so I don't have any experience with such applications, but Stripes seems fairly easy to use.
Sunday, November 4, 2007
25.WebAppQuestions
Posted by Michal Zielinski at 8:50 PM
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment