DOC PREVIEW
LETU COSC 2103 - Chapter 24: Servlets

This preview shows page 1-2-3-4-26-27-28-53-54-55-56 out of 56 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 56 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Chapter 24: Servlets24.1 Introduction24.1 Introduction (Cont.)24.2 Servlet Overview and Architecture24.2.1 Interface Servlet and the Servlet Life Cycle24.2.1 Interface Servlet and the Servlet Life Cycle (Cont.)24.2.2 HttpServlet Class24.2.2 HttpServlet Class (Cont.)24.2.3 HttpServletRequest Interface24.2.3 HttpServletRequest Interface (Cont.)24.2.4 HttpServletResponse Interface24.2.4 HttpServletResponse Interface (Cont.)24.3 Handling HTTP get RequestsWelcomeServlet Lines 4-5 Line 8 Lines 11-42 Line 15 Line 16 Lines 21-40WelcomeServlet Line 41WelcomeServlet.htmlProgram output24.3.1 Setting Up the Apache Tomcat Server24.3.1 Setting Up the Apache Tomcat Server (Cont.).24.3.2 Deploying a Web Application24.3.2 Deploying a Web Application (Cont.)web.xml Lines 5-37 Lines 8-11 Lines 13-16 Lines 19-29 Line 20 Lines 22-24 Lines 26-28web.xml Lines 26-28 Lines 32-35Slide 24Slide 2524.4 Handling HTTP get Requests Containing DataWelcomeServlet2 responds to a get request that contains data. Line 15WelcomeServlet2 responds to a get request that contains data. Line 39HTML document in which the form’s action invokes WelcomeServlet2 through the alias welcome2 specified in web.xml. Line 17HTML document in which the form’s action invokes WelcomeServlet2 through the alias welcome2 specified in web.xml. Program output24.4 Handling HTTP get Requests Containing Data (Cont.)24.5 Handling HTTP post RequestsWelcomeServlet3 responds to a post request that contains data. Lines 11-46WelcomeServlet3.javaHTML document in which the form’s action invokes WelcomeServlet3 through the alias welcome3 specified in web.xml. Lines 13-21HTML document in which the form’s action invokes WelcomeServlet3 through the alias welcome3 specified in web.xml. Program output24.5 Handling HTTP post Requests (Cont.)24.6 Redirecting Requests to Other ResourcesRedirectServletredirecting requests to other resources. Line 15 Lines 19-23 Line 20 Line 23 Lines 29-56RedirectServletredirecting requests to other resources. Lines 28-55RedirectServletredirecting requests to other resources.RedirectServlet.html document to demonstrate redirecting requests to other resources. Lines 15-16 Lines 17-18RedirectServlet.html document to demonstrate redirecting requests to other resources. Program output24.6 Redirecting Requests to other Resources (Cont.)24.7 Multi-Tier Applications: Using JDBC from a ServletSurveyServlet.java Multi-tier Web-based survey using XHTML, servlets and JDBC. Lines 16-38 Lines 20-21 Line 23 Lines 24-25 Lines 27-31SurveyServlet.java Multi-tier Web-based survey using XHTML, servlets and JDBC. Line 28SurveyServlet.java Multi-tier Web-based survey using XHTML, servlets and JDBC. Lines 64-65 Lines 72-73 Line 74SurveyServlet.java Multi-tier Web-based survey using XHTML, servlets and JDBC. Line 77 Line 78 Lines 83-84 Line 85SurveyServlet.java Multi-tier Web-based survey using XHTML, servlets and JDBC.SurveyServlet.java Multi-tier Web-based survey using XHTML, servlets and JDBC. Lines 130-136Survey.html document that allows users to submit survey responses to SurveyServlet.Slide 53Slide 5424.7 Multi-Tier Applications: Using JDBC from a Servlet (Cont.)24.8 Internet and World Wide Web Resources 2003 Prentice Hall, Inc. All rights reserved.Chapter 24: ServletsOutline24.1 Introduction24.2 Servlet Overview and Architecture24.2.1 Interface Servlet and the Servlet Life Cycle24.2.2 HttpServlet Class24.2.3 HttpServletRequest Interface24.2.4 HttpServletResponse Interface24.3 Handling HTTP get Requests24.3.1 Setting Up the Apache Tomcat Server24.3.2 Deploying a Web Application24.4 Handling HTTP get Requests Containing Data24.5 Handling HTTP post Requests24.6 Redirecting Requests to Other Resources24.7 Multi-Tier Applications: Using JDBC from a Servlet24.8 Internet and World Wide Web Resources 2003 Prentice Hall, Inc. All rights reserved.24.1 Introduction•Java networking capabilities–Socket-based and packet-based communications•Package java.net–Remote Method Invocation (RMI)•Package java.rmi–Servlets and Java Server Pages (JSP)•Request-response model•Packages javax.servlet javax.servlet.http javax.servlet.jsp javax.servlet.tagext•Form the Web tier of J2EE 2003 Prentice Hall, Inc. All rights reserved.24.1 Introduction (Cont.)•Servlets–Thin clients–Request/response mechanism–redirection•Tomcat–Jakarta project–Official reference implementation of the JSP and servlet standards 2003 Prentice Hall, Inc. All rights reserved.24.2 Servlet Overview and Architecture•Servlet container (servlet engine)–Server that executes a servlet•Web servers and application servers–Sun ONE Application Server–Microsoft’s Internet Information Server (IIS)–Apache HTTP Server–BEA’s WebLogic Application Server–IBM’s WebSphere Application Server–World Wide Web Consortium’s Jigsaw Web Server 2003 Prentice Hall, Inc. All rights reserved.24.2.1 Interface Servlet and the Servlet Life Cycle•Interface Servlet–All servlets must implement this interface–All methods of interface Servlet are invoked by servlet container•Servlet life cycle–Servlet container invokes the servlet’s init method–Servlet’s service method handles requests–Servlet’s destroy method releases servlet resources when the servlet container terminates the servlet•Servlet implementation–GenericServlet–HttpServlet 2003 Prentice Hall, Inc. All rights reserved.24.2.1 Interface Servlet and the Servlet Life Cycle (Cont.)Method Description void init( ServletConfig config ) The servlet container calls this method once during a servlet’s execution cycle to initialize the servlet. The ServletConfig argument is supplied by the servlet container that executes the servlet. ServletConfig getServletConfig() This method returns a reference to an object that implements interface ServletConfig. This object provides access to the servlet’s configuration information such as servlet initialization parameters and the servlet’s ServletContext, which provides the servlet with access to its environment (i.e., the servlet container in which the servlet executes). String getServletInfo() This method is defined by a servlet programmer to return a string containing servlet information such as the servlet’s author and version. void service( ServletRequest request, ServletResponse response ) The servlet container calls this method to respond to a client request to the servlet. void destroy()


View Full Document

LETU COSC 2103 - Chapter 24: Servlets

Documents in this Course
Arrays

Arrays

16 pages

Templates

Templates

17 pages

Methods

Methods

22 pages

Methods

Methods

22 pages

Arrays

Arrays

11 pages

Load more
Download Chapter 24: Servlets
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Chapter 24: Servlets and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Chapter 24: Servlets 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?