Sunteți pe pagina 1din 3

Study Guide for Exam 2 If a servlet is processing three requests at the same time, how many servlet objects

ts are in memory? 1 Model, View, Controller architecture 1. Model Corresponds to the bean 2. View Corresponds to the JSPs 3. Controller Corresponds to the controller (servlet) What is the main reason for using a controller helper to do all the work of a controller? It is able to use member variables Give an example of a variable that is stored in the helper base: HttpServletRequest request OR HttpServletResponse response What does the main Apache server do with a request from the browser? It will create spare servers to handle the requests. When is a servlet loaded intro memory? Whenever the application begins to read the .class files and starts up the Tomcat service What methods in the controller helper and bean are called when the EL statement $ {helper.data.hobby} is executed? getData() and getHobby() methods What is the purpose of the getData() method in the controller? It returns the JSPs What is the purpose of the getHobby() method in the controller? What would be the names of the accessors, in a bean, that correspond to the form elements with the following name: 1. thisIsFun getThisIsFun 2. tTHISISNOTFUN getTTHISISNOTFUN Explain why it is a bad idea to run Apache under inetd. The startup overhead would happen each time a request was made to the server making the server respond slowly. What determines if a member variable can be stored in the helper base? If the member variables are common to all controllers, like request and response. Explain what a spare server is in Apache. Spare servers are clones of the main server (daemon) which are started with the main server already initialized. The spare servers handle the requests made to the main server in order to reduce overhead. Apache the daemon (does not connect to a terminal) o Listens for requests o Uses OS to send messages Apache Directives 1. MinSpareServers Avoids startup times. Uses resources. 2. MaxSpareServers Handles IDLE servers. 3. StartServers 4. MaxClients Contains the number of ACTIVE servers (requests it can handle at a time.)

What is the command that will start Apache and use the conf files that are located in cgs4854/serverRoot directory of your home directory? httpd d ~amora017/cgs4854/serverRoot httpd.conf file 1. contains JKMount URL Tomcat: URLs forwarded to Tomcat 2. contains JKMount /*.jsp Tomcat: All JSPs sent to Tomcat 3. contains JKMount /book/* Tomcat: All URLs starting with book go to Tomcat. book can also be your username or manager If the process ID of the main Apache server is 123, then what is the complete command that is used to tell the server to reread its config files? kill HUP 123 Write the code that belongs in the doGet method of a controller that uses a controller helper to do its job public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { ControllerHelper helper = new ControllerHelper(request, response); Helper.doGet(); }

Write the java code for an accessor in a bean. The accessor is for a string property, named answer and will implement default validation. If the string is null or longer than 200 characters then the property is not valid. Use a default value of No answer. You will assume that the member variable you need have already been declared. If you use a helper method, then you must define it. public Boolean isValidAnswer() { Return answer != null && !answer.length > 200 } Public String getAnswer() { If(isValidAnswer()) { Return answer; } else { Return No answer; } }

Write the constructor for the controller helper class. Public ControllerHelper(HttpServletRequest request, HttpServletResponse response) { Super(request, response); }

S-ar putea să vă placă și