Example Processing a HTTP Request using the Model 2 Architecture
Sending the Request
The request starts when the user clicks on the input button on the main page. The request is sent via AJAX to the JBoss Application Web Container to the following URL (http://localhost:8080/hometownbank/example1?id=8596).

Associating a Servlet with a URL
Notice that this URL is directed to example1 in the hometownbank folder. The example1 URL is associated with the SampleServlet.java file defined in the web.xml file in the WEB-INF folder.

Processing the Request
The SampleServlet class first overrides the init() method. This method is called by the web container only once when the servlet is first loaded. The init() method instantiates an instance of the BusinessMethods class defined in the control layer. The web container then calls the doGET method. A new thread is created for each request when this method is called. The servlet then gets the input parameters from the request, calls the appropriate business method in the BusinessMethods class,, saves the returned object from the business method in an attribute (in the request object in this case) and forwards to the example1.jsp page.

Sending the Response
The example1.jsp page then receives control. All java classes referenced in the JSP page are first imported. The Person object saved in the request attributes is received and a variable is defined that has page scope. The rest of the JSP page consist of HTML tags, JSP scriptlets and JSP expressions.
