L06-Forms - Session 6 Forms Session 6 Form Dataset 1...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Session 6 – Forms 9/20/2010 1 © Robert Kelly, 2001 - 2010 Session 6 Form Dataset 1 Lecture Objectives Understand the relationship between HTML form elements and parameters that are passed to the servlet, particularly the form dataset © Robert Kelly, 2001 - 2010 2
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Session 6 – Forms 9/20/2010 2 © Robert Kelly, 2001 - 2010 Example – Form Input to a Servlet <head> <title>Who are you?</title> </head> <body> Input components are grouped by a form element <form method="get" action= "http://localhost:34908/CodeCSE336/helloyou.html"> What is your name? <input type="text" name="fullName" value="Enter name" /> <input type="submit" /> </form> </body> </html> © Robert Kelly, 2001 - 2010 3 Entering a name in this component changes the value of this form parameter HelloYou Servlet out.println(docType); String name = request.getParameter("fullName"); out.println("<html>"); © Robert Kelly, 2001 - 2010 4 out.println("<head><title> Hello, " + name + "</title></head>"); out.println("<body>"); out.println("Hello, " + name ); out.println("</body></html>"); out.close(); Servlet reads value of form data set
Background image of page 2
Session 6 – Forms 9/20/2010 3 © Robert Kelly, 2001 - 2010 Servlet Generates HTML out.println(docType); String name = request.getParameter("fullName"); out.println("<html>"); <html> <head><title>Hello Mark out.println("<head><title> Hello, " + name + "</title></head>"); out.println("<body>"); out.println("Hello, " + name ); out.println("</body></html>"); out.close(); <head><title>Hello, Mark Sanchez</title></head> <body> Hello, Mark Sanchez </body></html> © Robert Kelly, 2001 - 2010 5 HTML Form Element … A Form element contains component elements that are used to collect information on a Web page E h t t i ll h d l Each component typically has a name and a value The collection of name/value pairs is referred to as the form data set Form values are initially set to the value in the html, but changed when the user enters data The entire form is associated with a URL that will © Robert Kelly, 2001 - 2010 6 The entire form is associated with a URL that will process the data (usually after the submit button is pressed)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Session 6 – Forms 9/20/2010 4 © Robert Kelly, 2001 - 2010 HTML Form Element HTML control types : Button Text input (INPUT and TEXTAREA Buttons Submit Check boxes Radio buttons Menus Text input (INPUT and TEXTAREA) Password File select Hidden controls Object controls © Robert Kelly, 2001 - 2010
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 12

L06-Forms - Session 6 Forms Session 6 Form Dataset 1...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online