1 / 100

Unit 09 - Servlet Programming

Unit 09 - Servlet Programming.

Download Presentation

Unit 09 - Servlet Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Unit 09 - Servlet Programming 11.1 Introduction11.2 Servlet Overview and Architecture11.2.1 Interface Servlet and the Servlet Life Cycle11.2.2 HttpServlet Class11.2.3 HttpServletRequest Interface11.2.4 HttpServletResponse Interface11.3 Handling HTTP get Requests11.3.1 Setting Up the Apache Tomcat Server11.3.2 Deploying a Web Application11.4 Handling HTTP get Requests Containing Data11.5 Handling HTTP post Requests11.6 Redirecting Requests to Other Resources11.7 Session Tracking11.7.1 Cookies11.7.2 Session Tracking with HttpSession11.8 Multi-Tier Applications: Using JDBC from a Servlet 11.9 Servlet Context 11.10 Servlet filter11.11 Web application listener

  2. 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 • Servlets are modules of Java code that run in a server application to answer client requests.

  3. Servlet Overview and Architecture • Typical uses for Servlets include: • Processing and/or storing data submitted by an HTML form. • Providing dynamic content, e.g. returning the results of a database query to the client. • Managing state information on top of the stateless HTTP, e.g. for an online shopping cart system which manages shopping carts for many concurrent customers and maps every request to the right customer • Servlets make use of the Java standard extension classes in the packages javax.servlet (the basic Servlet framework) and javax.servlet.http (extensions of the Servlet framework for Servlets that answer HTTP requests). • Servlet container (servlet engine) • Server that executes a servlet

  4. Interface Servlet and the Servlet Life Cycle • Interface Servlet • All servlets must implement this interface • All methods of interface Servlet are invoked automatically • 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

  5. Interface Servlet and the Servlet Life Cycle (Cont.)

  6. HttpServlet Class • Overrides method service • Two most common HTTP request types • get requests • post requests • Method doGet responds to get requests • Method doPost responds to post requests • HttpServletRequest and HttpServletResponse objects

  7. HttpServletRequest Interface • Web server • creates an HttpServletRequest object • passes it to the servlet’s service method • HttpServletRequest object contains the request from the client

  8. HttpServletRequest Interface (Cont.)

  9. HttpServletResponse Interface HttpServletResponse object contains the request from the client

  10. Handling HTTP GET Requests • GET request • Retrieve the content of a URL • Example: WelcomeServlet • a servlet handles HTTP GET requests

  11. Import the javax.servlet and javax.servlet.http packages. Extends HttpServlet to handle HTTP get requests and HTTP post requests. Override method doGet to provide custom get request processing. Uses the response object’s getWriter method to obtain a reference to the PrintWriter object that enables the servlet to send content to the client. Uses the response object’s setContentType method to specify the content type of the data to be sent as the response to the client. Create the XHTML document by writing strings with the out object’s println method. 1 // WelcomeServlet.java 2 // A simple servlet to process get requests. 3 package com.alliant.test.servlets; 4 5 import javax.servlet.*; 6 import javax.servlet.http.*; 7 import java.io.*; 8 9 public class WelcomeServlet extends HttpServlet { 10 11 // process "get" requests from clients 12 protected void doGet( HttpServletRequest request, 13 HttpServletResponse response ) 14 throws ServletException, IOException 15 { 16 response.setContentType( "text/html" ); 17 PrintWriter out = response.getWriter(); 18 19 // send XHTML page to client 20 21 // start XHTML document 22 out.println( "<?xml version = \"1.0\"?>" ); 23 24 out.println( "<!DOCTYPE html PUBLIC \"-//W3C//DTD " + 25 "XHTML 1.0 Strict//EN\" \"http://www.w3.org" + 26 "/TR/xhtml1/DTD/xhtml1-strict.dtd\">" ); 27 28 out.println( 29 "<html xmlns = \"http://www.w3.org/1999/xhtml\">" ); 30 31 // head section of document 32 out.println( "<head>" ); 33 out.println( "<title>A Simple Servlet Example</title>" ); 34 out.println( "</head>" ); 35 WelcomeServlet that responds to a simple HTTP get request.Lines 5-6Line 9Lines 12-44Line 16Line 17Lines 22-42

  12. Closes the output stream, flushes the output buffer and sends the information to the client. 36 // body section of document 37 out.println( "<body>" ); 38 out.println( "<h1>Welcome to Servlets!</h1>" ); 39 out.println( "</body>" ); 40 41 // end XHTML document 42 out.println( "</html>" ); 43 out.close(); // close stream to complete the page 44 } 45 } WelcomeServlet that responds to a simple HTTP get request.Line 43

  13. 1 <?xml version ="1.0"?> 2 <!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Strict//EN" 3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 4 5 <!-- WelcomeServlet.html --> 6 7 <html xmlns = "http://www.w3.org/1999/xhtml"> 8 <head> 9 <title>Handling an HTTP Get Request</title> 10 </head> 11 12 <body> 13 <form action ="/test/welcome1" method ="get"> 14 15 <p><label>Click the button to invoke the servlet 16 <input type = "submit"value ="Get HTML Document"/> 17 </label></p> 18 19 </form> 20 </body> 21 </html> HTML document in which the form’s action invokes WelcomeServlet through the alias welcome1 specified in web.xml.

  14. Setting Up the Apache Tomcat Server • Download Tomcat (version 5.0.27) • http://jakarta.apache.org/builds/jakarta-tomcat/ • Define environment variables • JAVA_HOME • CATALINA_HOME • Start the Tomcat server • CATALINA_HOME\bin\startup.bat • Launch the Tomcat server • http://localhost:8080/ • Shutdown the Tomcat server • CATALINA_HOME\bin\shutdown.bat

  15. Setting Up the Apache Tomcat Server (Cont.). Tomcat documentation home page. (Courtesy of The Apache Software Foundation.)

  16. Deploying a Web Application • Web applications • JSPs, servlets and their supporting files • Deploying a Web application • Directory structure • Context root • Web application archive file (WAR file) OR Web application folder • Deployment descriptor • web.xml

  17. Deploying a Web Application (Cont.)

  18. Element web-app defines the configuration of each servlet in the Web application and the servlet mapping for each servlet. Element display-name specifies a name that can be displayed to the administrator of the server on which the Web application is installed. Element description specifies a description of the Web application that might be displayed to the administrator of the server. Element servlet-name is the name for the servlet. Element description specifies a description for this particular servlet. Element servlet describes a servlet. Element servlet-class specifies compiled servlet’s fully qualified class name. 1 <!DOCTYPE web-app PUBLIC 2 "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" 3 "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"> 4 5 <web-app> 6 7 <!-- General description of your Web application --> 8 <display-name> 9 Sample 10 Servlet Examples 11 </display-name> 12 13 <description> 14 This is the Web application in which we 15 demonstrate our JSP and Servlet examples. 16 </description> 17 18 <!-- Servlet definitions --> 19 <servlet> 20 <servlet-name>welcome1</servlet-name> 21 22 <description> 23 A simple servlet that handles an HTTP get request. 24 </description> 25 26 <servlet-class> 27 com.alliant.test.servlets.WelcomeServlet 28 </servlet-class> 29 </servlet> 30 Deployment descriptor (web.xml) for the advjhtp1 Web application.Lines 5-37Lines 8-11Lines 13-16Lines 19-29Line 20 Lines 22-24Lines 26-28

  19. Element servlet-mapping specifies servlet-name and url-pattern elements. 31 <!-- Servlet mappings --> 32 <servlet-mapping> 33 <servlet-name>welcome1</servlet-name> 34 <url-pattern>/welcome1</url-pattern> 35 </servlet-mapping> 36 37 </web-app> Deployment descriptor (web.xml) for the advjhtp1 Web application.Lines 32-35

  20. Deploying a Web Application (Cont.) • Invoke WelcomeServlet example • /test/welcome1 • /test specifies the context root • /welcome1 specifies the URL pattern • URL pattern formats • Exact match • /test/welcome1 • Path mappings • /test/example/* • Extension mappings • *.jsp • Default servlet • /test/example/

  21. Deploying a Web Application (Cont.)

  22. Handling HTTP GET Requests Containing Data • Servlet WelcomeServlet2 • Responds to a get request that contains data

  23. The request object’s getParameter method receives the parameter name and returns the corresponding String value. 1 // WelcomeServlet2.java 2 // Processing HTTP get requests containing data. 3 package com.alliant.test.servlets; 4 5 import javax.servlet.*; 6 import javax.servlet.http.*; 7 import java.io.*; 8 9 public class WelcomeServlet2 extends HttpServlet { 10 11 // process "get" request from client 12 protected void doGet( HttpServletRequest request, 13 HttpServletResponse response ) 14 throws ServletException, IOException 15 { 16 String firstName = request.getParameter( "firstname" ); 17 18 response.setContentType( "text/html" ); 19 PrintWriter out = response.getWriter(); 20 21 // send XHTML document to client 22 23 // start XHTML document 24 out.println( "<?xml version = \"1.0\"?>" ); 25 26 out.println( "<!DOCTYPE html PUBLIC \"-//W3C//DTD " + 27 "XHTML 1.0 Strict//EN\" \"http://www.w3.org" + 28 "/TR/xhtml1/DTD/xhtml1-strict.dtd\">" ); 29 30 out.println( 31 "<html xmlns = \"http://www.w3.org/1999/xhtml\">" ); 32 WelcomeServlet2 responds to a get request that contains data.Line 16

  24. Uses the result of line 16 as part of the response to the client. 33 // head section of document 34 out.println( "<head>" ); 35 out.println( 36 "<title>Processing get requests with data</title>" ); 37 out.println( "</head>" ); 38 39 // body section of document 40 out.println( "<body>" ); 41 out.println( "<h1>Hello " + firstName + ",<br />" ); 42 out.println( "Welcome to Servlets!</h1>" ); 43 out.println( "</body>" ); 44 45 // end XHTML document 46 out.println( "</html>" ); 47 out.close(); // close stream to complete the page 48 } 49 } WelcomeServlet2 responds to a get request that contains data.Line 41

  25. Get the first name from the user. 1 <?xml version ="1.0"?> 2 <!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Strict//EN" 3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 4 5 <!-- WelcomeServlet2.html --> 6 7 <html xmlns ="http://www.w3.org/1999/xhtml"> 8 <head> 9 <title>Processing get requests with data</title> 10 </head> 11 12 <body> 13 <form action ="/test/welcome2"method ="get"> 14 15 <p><label> 16 Type your first name and press the Submit button 17 <br /><input type ="text"name = "firstname"/> 18 <input type = "submit"value ="Submit" /> 19 </p></label> 20 21 </form> 22 </body> 23 </html> HTML document in which the form’s action invokes WelcomeServlet2 through the alias welcome2 specified in web.xml.Line 17

  26. HTML document in which the form’s action invokes WelcomeServlet2 through the alias welcome2 specified in web.xml. Program output

  27. Handling HTTP get Requests Containing Data (Cont.)

  28. Handling HTTP post Requests • HTTP post request • Post data from an HTML form to a server-side form handler • Browsers cache Web pages • Servlet WelcomeServlet3 • Responds to a post request that contains data

  29. Define a doPost method to responds to post requests. 1 // WelcomeServlet3.java 2 // Processing post requests containing data. 3 package com.deitel.advjhtp1.servlets; 4 5 import javax.servlet.*; 6 import javax.servlet.http.*; 7 import java.io.*; 8 9 public class WelcomeServlet3 extends HttpServlet { 10 11 // process "post" request from client 12 protected void doPost( HttpServletRequest request, 13 HttpServletResponse response ) 14 throws ServletException, IOException 15 { 16 String firstName = request.getParameter( "firstname" ); 17 18 response.setContentType( "text/html" ); 19 PrintWriter out = response.getWriter(); 20 21 // send XHTML page to client 22 23 // start XHTML document 24 out.println( "<?xml version = \"1.0\"?>" ); 25 26 out.println( "<!DOCTYPE html PUBLIC \"-//W3C//DTD " + 27 "XHTML 1.0 Strict//EN\" \"http://www.w3.org" + 28 "/TR/xhtml1/DTD/xhtml1-strict.dtd\">" ); 29 30 out.println( 31 "<html xmlns = \"http://www.w3.org/1999/xhtml\">" ); 32 WelcomeServlet3 responds to a post request that contains data.Lines 12-48

  30. 33 // head section of document 34 out.println( "<head>" ); 35 out.println( 36 "<title>Processing post requests with data</title>" ); 37 out.println( "</head>" ); 38 39 // body section of document 40 out.println( "<body>" ); 41 out.println( "<h1>Hello " + firstName + ",<br />" ); 42 out.println( "Welcome to Servlets!</h1>" ); 43 out.println( "</body>" ); 44 45 // end XHTML document 46 out.println( "</html>" ); 47 out.close(); // close stream to complete the page 48 } 49 } WelcomeServlet3.java

  31. Provide a form in which the user can input a name in the text input element firstname, then click the Submit button to invoke WelcomeServlet3. 1 <?xml version ="1.0"?> 2 <!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Strict//EN" 3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 4 5 <!-- Fig. 9.15: WelcomeServlet3.html --> 6 7 <html xmlns ="http://www.w3.org/1999/xhtml"> 8 <head> 9 <title>Handling an HTTP Post Request with Data</title> 10 </head> 11 12 <body> 13 <form action = "/test/welcome3"method = "post"> 14 15 <p><label> 16 Type your first name and press the Submit button 17 <br /><input type ="text"name = "firstname" /> 18 <input type ="submit"value = "Submit" /> 19 </label></p> 20 21 </form> 22 </body> 23 </html> HTML document in which the form’s action invokes WelcomeServlet3 through the alias welcome3 specified in web.xml.Lines 13-21

  32. HTML document in which the form’s action invokes WelcomeServlet3 through the alias welcome3 specified in web.xml.Program output

  33. Handling HTTP post Requests (Cont.)

  34. Redirecting Requests to Other Resources • Servlet RedirectServlet • Redirects the request to a different resource

  35. Obtains the page parameter from the request. Determine if the value is either “deitel” or “welcome1” Redirects the request to www.deitel.com. Redirects the request to the servlet WelcomeServlet. Output a Web page indicating that an invalid request was made if method sendRedirect is not called. 1 // RedirectServlet.java 2 // Redirecting a user to a different Web page. 3 package com.deitel.advjhtp1.servlets; 4 5 import javax.servlet.*; 6 import javax.servlet.http.*; 7 import java.io.*; 8 9 public class RedirectServlet extends HttpServlet { 10 11 // process "get" request from client 12 protected void doGet( HttpServletRequest request, 13 HttpServletResponse response ) 14 throws ServletException, IOException 15 { 16 String location = request.getParameter( "page" ); 17 18 if ( location != null ) 19 20 if ( location.equals( “alliant" ) ) 21 response.sendRedirect( "http://www.alliant-corp.com" ); 22 else 23 if ( location.equals( "welcome1" ) ) 24 response.sendRedirect( "welcome1" ); 25 26 // code that executes only if this servlet 27 // does not redirect the user to another page 28 29 response.setContentType( "text/html" ); 30 PrintWriter out = response.getWriter(); 31 Redirecting requests to other resources.Line 16Lines 20-24Line 21Line 24Lines 29-56

  36. 32 // start XHTML document 33 out.println( "<?xml version = \"1.0\"?>" ); 34 35 out.println( "<!DOCTYPE html PUBLIC \"-//W3C//DTD " + 36 "XHTML 1.0 Strict//EN\" \"http://www.w3.org" + 37 "/TR/xhtml1/DTD/xhtml1-strict.dtd\">" ); 38 39 out.println( 40 "<html xmlns = \"http://www.w3.org/1999/xhtml\">" ); 41 42 // head section of document 43 out.println( "<head>" ); 44 out.println( "<title>Invalid page</title>" ); 45 out.println( "</head>" ); 46 47 // body section of document 48 out.println( "<body>" ); 49 out.println( "<h1>Invalid page requested</h1>" ); 50 out.println( "<p><a href = " + 51 "\"servlets/RedirectServlet.html\">" ); 52 out.println( "Click here to choose again</a></p>" ); 53 out.println( "</body>" ); 54 55 // end XHTML document 56 out.println( "</html>" ); 57 out.close(); // close stream to complete the page 58 } 59 } Redirecting requests to other resources.

  37. Provide hyperlinks that allow the user to invoke the servlet RedirectServlet. 1 <?xml version ="1.0"?> 2 <!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Strict//EN" 3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 4 5 <!-- RedirectServlet.html --> 6 7 <html xmlns = "http://www.w3.org/1999/xhtml"> 8 <head> 9 <title>Redirecting a Request to Another Site</title> 10 </head> 11 12 <body> 13 <p>Click a link to be redirected to the appropriate page</p> 14 <p> 15 <a href = "/test/redirect?page=alliant"> 16 www.alliant-corp.com</a><br /> 17 <a href = "/test/redirect?page=welcome1"> 18 Welcome servlet</a> 19 </p> 20 </body> 21 </html> RedirectServlet.html document to demonstrate redirecting requests to other resources.Lines 15-16Lines 17-18

  38. Redirecting Requests to other Resources (Cont.)

  39. Session Tracking • Personalization • Privacy invasion • HTTP – stateless protocol • Does not support persistent information • Track clients individually • Cookies • Session tracking • hidden type input • URL rewriting

  40. Cookies • Stored on the user’s computer for retrieval later • Text-based data sent by servlets • Maximum age of a cookie • Deleted automatically when they expire • Servlet CookieServlet • Handles both get and post requests

  41. Method init populates books with four key/value pair of books. Uses method getParameter to obtain the user’s language selection. Gets the ISBN number for the selected language from books. Creates a new Cookie object, using the language and isbn values as the cookie name and cookie value, respectively. Adds the cookie to the response with method addCookie of interface HttpServletResponse. 1 // CookieServlet.java 2 // Using cookies to store data on the client computer. 3 package com.alliant.test.servlets; 4 5 import javax.servlet.*; 6 import javax.servlet.http.*; 7 import java.io.*; 8 import java.util.*; 9 10 public class CookieServlet extends HttpServlet { 11 private final Map books = new HashMap(); 12 13 // initialize Map books 14 public void init() 15 { 16 books.put( "C","0130895725" ); 17 books.put( "C++", "0130895717" ); 18 books.put( "Java", "0130125075" ); 19 books.put( "VB6", "0134569555" ); 20 } 21 22 // receive language selection and send cookie containing 23 // recommended book to the client 24 protected void doPost( HttpServletRequest request, 25 HttpServletResponse response ) 26 throws ServletException, IOException 27 { 28 String language = request.getParameter( "language" ); 29 String isbn = books.get( language ).toString(); 30 Cookie cookie = new Cookie( language, isbn ); 31 32 response.addCookie( cookie ); // must precede getWriter 33 response.setContentType( "text/html" ); 34 PrintWriter out = response.getWriter(); 35 Storing user data on the client computer with cookies.Lines 14-20Line 28Line 29 Line 30Line 32

  42. 36 // send XHTML page to client 37 38 // start XHTML document 39 out.println( "<?xml version = \"1.0\"?>" ); 40 41 out.println( "<!DOCTYPE html PUBLIC \"-//W3C//DTD " + 42 "XHTML 1.0 Strict//EN\" \"http://www.w3.org" + 43 "/TR/xhtml1/DTD/xhtml1-strict.dtd\">" ); 44 45 out.println( 46 "<html xmlns = \"http://www.w3.org/1999/xhtml\">" ); 47 48 // head section of document 49 out.println( "<head>" ); 50 out.println( "<title>Welcome to Cookies</title>" ); 51 out.println( "</head>" ); 52 53 // body section of document 54 out.println( "<body>" ); 55 out.println( "<p>Welcome to Cookies! You selected " + 56 language + "</p>" ); 57 58 out.println( "<p><a href = " + 59 "\"/advjhtp1/servlets/CookieSelectLanguage.html\">" + 60 "Click here to choose another language</a></p>" ); 61 62 out.println( "<p><a href = \"/advjhtp1/cookies\">" + 63 "Click here to get book recommendations</a></p>" ); 64 out.println( "</body>" ); 65 66 // end XHTML document 67 out.println( "</html>" ); 68 out.close(); // close stream 69 } 70 Storing user data on the client computer with cookies.

  43. Retrieves the cookies from the client using HttpServletRequest method getCookies, which returns an array of Cookie objects. 71 // read cookies from client and create XHTML document 72 // containing recommended books 73 protected void doGet( HttpServletRequest request, 74 HttpServletResponse response ) 75 throws ServletException, IOException 76 { 77 Cookie cookies[] = request.getCookies(); // get cookies 78 79 response.setContentType( "text/html" ); 80 PrintWriter out = response.getWriter(); 81 82 // start XHTML document 83 out.println( "<?xml version = \"1.0\"?>" ); 84 85 out.println( "<!DOCTYPE html PUBLIC \"-//W3C//DTD " + 86 "XHTML 1.0 Strict//EN\" \"http://www.w3.org" + 87 "/TR/xhtml1/DTD/xhtml1-strict.dtd\">" ); 88 89 out.println( 90 "<html xmlns = \"http://www.w3.org/1999/xhtml\">" ); 91 92 // head section of document 93 out.println( "<head>" ); 94 out.println( "<title>Recommendations</title>" ); 95 out.println( "</head>" ); 96 97 // body section of document 98 out.println( "<body>" ); 99 100 // if there are any cookies, recommend a book for each ISBN 101 if ( cookies != null && cookies.length != 0 ) { 102 out.println( "<h1>Recommendations</h1>" ); 103 out.println( "<p>" ); 104 Storing user data on the client computer with cookies.Line 77

  44. 105 // get the name of each cookie 106 for ( int i = 0; i < cookies.length; i++ ) 107 out.println( cookies[ i ].getName() + 108 " How to Program. ISBN#: " + 109 cookies[ i ].getValue() + "<br />" ); 110 111 out.println( "</p>" ); 112 } 113 else { // there were no cookies 114 out.println( "<h1>No Recommendations</h1>" ); 115 out.println( "<p>You did not select a language.</p>" ); 116 } 117 118 out.println( "</body>" ); 119 120 // end XHTML document 121 out.println( "</html>" ); 122 out.close(); // close stream 123 } 124 } Storing user data on the client computer with cookies.

  45. 1 <?xml version ="1.0"?> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 4 5 <!-- CookieSelectLanguage.html --> 6 7 <html xmlns = "http://www.w3.org/1999/xhtml"> 8 <head> 9 <title>Using Cookies</title> 10 </head> 11 12 <body> 13 <form action = "/advjhtp1/cookies"method ="post"> 14 15 <p>Select a programming language:</p> 16 <p> 17 <input type ="radio"name ="language" 18 value ="C"/>C <br /> 19 20 <input type = "radio"name ="language" 21 value ="C++" />C++ <br /> 22 23 <!-- this radio button checked by default --> 24 <input type = "radio"name ="language" 25 value = "Java" checked ="checked"/>Java<br /> 26 27 <input type = "radio" name ="language" 28 value ="VB6"/>VB 6 29 </p> 30 31 <p><input type ="submit"value = "Submit"/></p> 32 33 </form> 34 </body> 35 </html> CookieSelectLanguage.html document for selecting a programming language and posting the data to the CookieServlet.

  46. CookieSelectLanguage.html document for selecting a programming language and posting the data to the CookieServlet. Program output

  47. CookieSelectLanguage.html document for selecting a programming language and posting the data to the CookieServlet. Program output

  48. Cookies (Cont.)

  49. Cookies (Cont.) (Part 1 of 2) Important methods of class Cookie.

  50. Cookies (Cont.)

More Related