Monday, November 5, 2007

WebAppQuestions

Questions:

1. Explain in your own words the meaning of the web "request-response cycle".
This is the cycle where the client, usually represented as a user, sends out a request to the server, usually represented as a website, and then the server gathers the necessary information to construct a response, and sends back the response the client and waits for the next request to complete the cycle.

2. Explain how servlets facilitate processing of the request-response cycle.
The servlets use the ServletRequest interface to define methods for getting information from the requests, which contains the data passed between a client and the servlet; and it uses the ServletResponse interface to defind methods for constructing responses, which contain data passed between a server and the client.

3. How do you login to the Tomcat Manager?
In order to login to the Tomcat Manager, the user must first start up the Tomcat server, then open the browser and type in http://localhost:8080, click on the Tomcat Manager link, where the user will be asked for user name and password for login. The information is defined in the file $CATALINA_HOME/conf/tomcat-user.xml.

4.What is the Tomcat Manager used for in the StackStripes application?
In the StackStripes application, the Tomcat Manager is used to deploy and undeploy the application and maintain the sessions for the 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 named after the application, for instance, StackStripes. Then inside the directory, there are META-INF and WEB-INF folders, and some jsp files which might be under some subfolders. The jsp files define how the web application will look like in the browser. The META-INF folder contains the manifest file for the application, and the WEB-INF folder contains the classes files for the application, and the library used in the application, which usually are jar files. The WEB-INF folder also contains a web.xml file, which is the configuration for the Stripes.

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. This target must invoke the Ant task “war” to create a war file and specifies a configuration file usually named web.xml. In the StackStripe application, this is done inside the war taget in the build.xml file.

7. How do you install a war directory in a running Tomcat server? What information does the Ant task need to accomplish this?
One way to deploy the application in a running Tomcat server is to set the autoDeploy attribute to “true”. Alternative way is to do it via an Ant task. The necessary information for the task include: the war file, and the deploy parameters and the install URL.

8. What is the "Model2" architecture? What are its advantages?
Model2 is an architectural pattern used in software engineering. It separates the data (model) and user interfaces (view), and uses a controller to connect the two components, so that they do not affect each other when modified. It has the greater scalability and modularity.

9. What are JSP pages? How are they related to servlets?
JSP pages are used to create web content that has both static and dynamic components. It relates to the servlets by accepting the dynamic request.

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 the JSP page must be compiled into a Java Servlet, which is a piece of pure Java code to go through, and it does not require this process after the first time access. It is store under the $J2EE_HOME directory.

11. What are JSTL tags? Why are they useful? What is an example JSTL tag from the StackStripes system?
JSTL tags are a collection of tag libraries that provide common functionality while writing JSP pages. They are useful because they fit in HTML better than Java code, and provide reusability as well as Expression Language, which is very convenient. In the StackStripes system, the
JSTL tag is used.

12. What are Stripes tags? Why are they useful? What is an example Stripes tag from the StackStripes system?
Stripes tags are the ones start with the prefix “stripe:” They are useful because they link the JSP pages to the Java classes automatically and provide very powerful functionality. In the StackStripes system, the
Stripes tags are used.

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 open source software that can provide automated testing by emulate the browser behavior. It is different from JUnit because it provides easy way to write tests that can simulate the user behavior on a web, such as clicking a link. It is very useful for testing web application. In the StackStripes system, it is used to test the task of user clicking the buttons on the web.

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?
To implement the Double It button, a new JavaBean method for the double operation must be created, also a new form must be created in the JSP page. Everything else that worked before do not have to be changed. This is the advantage of MVC design, it separate the data, which is the Stack model, with the view, which is the JSP page. So when we change the JSP page, it does not affect the data.

15. What are the equivalence classes that need to be tested for the Double It button?
The class needed to be tested for the Double It button is StackActionBean because it is related to the user interface (view). The StackModel class has nothing to do with it, thus it does not require testing.

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 enforce there is always only one instance exists for the class. In the StackStipes system, the stack is implemented in this way. This is needed because it prevent multiple stack is being used by different users.

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 StackModel is tested on the client side, and the StackActionBean is tested on the server side. Emma combines the coverage from both side to create appropriate coverage data.

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 if Tomcat server is running
tomcat.undeploy – undepoly the application if there is one running on the server
compile – compile the source code
war – create the new war file using the web files
tomcat.deploy – deploy the application on the server
junit.tool – runs the JUnit tests
junit.report – report the JUnit results by creating HTML report file
junit – ensure the junit.tool and junit.report has been run

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 used a little ColdFusion framework before, but I only set up the database on the server side and it is a local server as well. Many things are quite similar in the two frameworks, they both have their own tags to do specific tasks that are more powerful than normal HTML tags, and they both have a manager-like feather to maintain the sessions.

No comments: