Few weeks back i started reading Java™ How to Program, Sixth Edition By H. M. Deitel - Deitel & Associates, Inc., P. J. Deitel - Deitel & Associates, Inc.
Nice book written By H. M. Deitel - Deitel & Associates, Inc., P. J. Deitel - Deitel & Associates, Inc.
I wanted to share few quotations found the book from the 26th chapter.
1) The classes and interfaces used to define servlets are found in packages javax.servlet and javax.servlet.http.
2) URLs represent files or directories and can represent complex tasks, such as database lookups and Internet searches.
3) JavaServer Pages technology, an extension of servlet technology, simplifies the process of creating pages by separating presentation from content.
4) Servlets are normally executed by the servlet container component of a Web application server.
5) All servlets must implement the Servlet interface. The methods of interface Servlet are invoked automatically by the servlet container.
6) A servlet's life cycle begins when the servlet container loads the servlet into memorynormally in response to the first request to that servlet. Before the servlet can handle the first request, the servlet container invokes the servlet's init method. After init completes execution, the servlet can respond to its first request. All requests are handled by a servlet's service method, which may be called many times during the servlet's life cycle. When the servlet container terminates the servlet, the servlet's destroy method is called to release servlet resources.
7) The key method in every servlet is method service, which receives both a ServletRequest object and a ServletResponse object. These objects provide access to input and output streams that allow the servlet to read data from and send data to the client. Commonly, this method should not be overridden.
8) Servlets typically extend class HttpServlet, which overrides method service to distinguish between the typical requests received from a client Web browser. The two most common HTTP request types (also known as request methods) are get and post.
9) Class HttpServlet defines methods doGet and doPost to respond to get and post requests from a client, respectively.
10) Methods doGet and doPost receive as arguments an HttpServletRequest object and an HttpServletResponse object that enable interaction between the client and the server.
11) A response is sent to the client through a PrintWriter object returned by the getWriter method of the HttpServletResponse object.
12) The HttpServletResponse object's setContentType method specifies the content type of the response to the client. This enables the client browser to understand and handle the content.
13) The server localhost (IP address 127.0.0.1) is a well-known host name on computers that support TCP/IP-based networking protocols such as HTTP. This host name can be used to test TCP/IP applications on the local computer.
14) The Tomcat server awaits requests from clients on port 8080. This port number must be specified as part of the URL to request a servlet running in Tomcat.
15) Tomcat is a fully functional implementation of the JSP and servlet standards. It includes a Web server, so it can be used as a standalone test container for JSPs and servlets.
16) JSPs, servlets and their supporting files are deployed as part of Web applications. In Tomcat, Web applications are deployed in the webapps subdirectory of the Tomcat installation.
17) A Web application has a well-known directory structure in which all the files that are part of the application reside. This directory structure can be set up by the Tomcat server administrator in the webapps directory, or the entire directory structure can be archived in a Web application archive file (i.e., .war file).
18) WAR files are typically placed in the webapps directory. When the Tomcat server begins execution, it extracts the contents of the WAR file into the appropriate webapps subdirectory structure.
19) The Web application directory structure is separated into a context rootthe top-level directory for an entire Web applicationand several subdirectories. The context root is the root directory for the Web application.
20) All the JSPs, HTML documents, servlets and supporting files such as images and class files reside in the root directory or its subdirectories.
21) The WEB-INF directory contains the Web application deployment descriptor (web.xml), which is required to deploy a Web application.
22) The WEB-INF/classes directory contains the servlet class files and other supporting class files used in a Web application.
23) The WEB-INF/lib directory contains Java archive (JAR) files that may include servlet class files and other supporting class files used in a Web application.
24) Tomcat uses the directory names in the webapps subdirectory as the context names.
25) HTTP get requests can be typed directly into your browser's Address or Location field.
26) Parameters are passed as name-value pairs in a get request. A ? sepasrates the URL from the data passed as part of a get request. Name-value pairs are passed with the name and the value separated by =. Two or more name-value pairs are separated by &.
27) Method getParameter of HttpServletRequest receives the parameter name as an argument and returns the corresponding String value, or null if the parameter is not part of the request.
28) An HTTP post request is often used to post data from a Web-page form to a server-side form handler that processes the data. HTTP post requests are commonly used for passing sensitive data.
29) Method doPost receives the same two arguments as doGetan object that implements interface HttpServletRequest to represent the client's request and an object that implements interface HttpServletResponse to represent the servlet's response.
30) Method sendRedirect of HttpServletResponse redirects a request to the specified URL.
31) When a servlet uses a relative path to reference another static or dynamic resource, the servlet assumes the same context root unless a complete URL is specified for the resource.
32) Once method sendRedirect executes, processing of the request by the servlet that called send-Redirect terminates.
33) When redirecting requests, the request parameters from the original request are passed as parameters to the new request. Additional request parameters can also be passed. New parameters are added to the existing request parameters. If a new parameter has the same name as an existing parameter, the new parameter value takes precedence over the original value. However, all the values are still passed.
34) The complete set of values for a given request-parameter name can be obtained by calling method getParameterValues of HttpServletRequest, which receives the parameter name as an argument and returns an array of Strings containing the parameter values in order from the most recently to the least recently added.
35) Many of today's applications are three-tier distributed applications, consisting of a user interface, business logic and database access.
36) In multitier architectures, Web servers are often used in the middle tier. Server-side components, such as servlets, execute in an application server alongside the Web server. These components provide the business logic that manipulates data from databases and communicates with client Web browsers.
37) Servlet method init takes a ServletConfig argument, which provides the servlet with information about its initialization parameters specified in a servlet element in the deployment descriptor. Each parameter appears in an init-param element with child elements param-name and param-value.
38) Web application developers can specify an ordered list of welcome files to be loaded when the request URL is not mapped to a servlet. These files are typically HTML or JSP documents.
39) Welcome files are defined using the welcome-file-list element in the deployment descriptor.
40) Element welcome-file-list contains one or more welcome-file elements. Each welcome-file element specifies the partial URL of a welcome file without a leading or trailing /.
About the Authors
Dr. Harvey M. Deitel, Chairman and Chief Strategy Officer of Deitel & Associates, Inc., has 43 years experience in the computing field, including extensive industry and academic experience. Dr. Deitel earned B.S. and M.S. degrees from the Massachusetts Institute of Technology and a Ph.D. from Boston University. He worked on the pioneering virtual-memory operating-systems projects at IBM and MIT that developed techniques now widely implemented in systems such as UNIX, Linux and Windows XP. He has 20 years of college teaching experience, including earning tenure and serving as the Chairman of the Computer Science Department at Boston College before founding Deitel & Associates, Inc., with his son, Paul J. Deitel. He and Paul are the co-authors of several dozen books and multimedia packages and they are writing many more. With translations published in Japanese, German, Russian, Spanish, Traditional Chinese, Simplified Chinese, Korean, French, Polish, Italian, Portuguese, Greek, Urdu and Turkish, the Deitels' texts have earned international recognition. Dr. Deitel has delivered hundreds of professional seminars to major corporations, academic institutions, government organizations and the military.
Paul J. Deitel, CEO and Chief Technical Officer of Deitel & Associates, Inc., is a graduate of the MIT's Sloan School of Management, where he studied Information Technology. Through Deitel & Associates, Inc., he has delivered Java, C, C++, Internet and World Wide Web courses to industry clients, including IBM, Sun Microsystems, Dell, Lucent Technologies, Fidelity, NASA at the Kennedy Space Center, the National Severe Storm Laboratory, Compaq, White Sands Missile Range, Rogue Wave Software, Boeing, Stratus, Cambridge Technology Partners, Open Environment Corporation, One Wave, Hyperion Software, Adra Systems, Entergy, CableData Systems and many other organizations. Paul is one of the most experienced Java corporate trainers having taught about 100 professional Java training courses. He has also lectured on C++ and Java for the Boston Chapter of the Association for Computing Machinery. He and his father, Dr. Harvey M. Deitel, are the world's best-selling Computer Science textbook authors.
Tuesday, 10 March 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment