03-Form-Data - 2010 Marty Hall Originals of Slides and Source Code for Examples http/courses.coreservlets.com/Course-Materials/csajsp2.html

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

View Full Document Right Arrow Icon
© 2010 Marty Hall Handling the Client Handling the Client Request: Form Data Originals of Slides and Source Code for Examples: http://courses.coreservlets.com/Course-Materials/csajsp2.html Customized Java EE Training: http://courses.coreservlets.com/ Servlets, JSP, JSF 2.0, Struts, Ajax, GWT 2.0, Spring, Hibernate, SOAP & RESTful Web Services, Java 6. Developed and taught by well-known author and developer. At public venues or onsite at your location. 3 © 2010 Marty Hall For live Java EE training, please see training courses at http://courses.coreservlets.com/. Servlets, JSP, Struts, JSF 1. x , JSF 2.0, Ajax (with jQuery, Dojo, Prototype, Ext-JS, Google Closure, etc.), GWT 2.0 (with GXT), Java 5, Java 6, SOAP-based and RESTful Web Services, Spring, Hibernate/JPA, and customized combinations of topics. Taught by the author of Core Servlets and JSP , More Servlets and JSP , and this tutorial. Available at public venues, or customized versions can be held on-site at your organization. Contact [email protected] for details.
Background image of page 1

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

View Full DocumentRight Arrow Icon
Agenda The role of form data Creating and submitting HTML forms Reading individual request parameters Reading the entire set of request parameters Handling missing and malformed data Dealing with incomplete form submissions Filtering special characters out of the Filtering special characters out of the request parameters 5 © 2010 Marty Hall Form Basics Customized Java EE Training: http://courses.coreservlets.com/ Servlets, JSP, JSF 2.0, Struts, Ajax, GWT 2.0, Spring, Hibernate, SOAP & RESTful Web Services, Java 6. Developed and taught by well-known author and developer. At public venues or onsite at your location. 6
Background image of page 2
The Role of Form Data Example URL at online travel agent http://host/path ?user=Marty+Hall&origin=bwi&dest=lax Names come from HTML author; values from end user Parsing form (query) data in traditional CG Parsing form (query) data in traditional CGI Read the data one way (QUERY_STRING) for GET requests, another way (standard input) for POST requests Chop pairs at ampersands, then separate parameter names (left of the =) from parameter values (right of the =) URL decode values (e.g., "%7E" becomes "~") Greatly simplified in servlets Use request getParameter in all cases Use request.getParameter in all cases. Gives URL-decoded result 7 Creating Form Data: HTML Forms <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD><TITLE>A Sample Form Using GET</TITLE></HEAD> <BODY BGCOLOR="#FDF5E6"> <H2 ALIGN="CENTER">A Sample Form Using GET</H2> You normally use a relative URL for the ACTION. This URL is just for testing because I am <FORM ACTION="http://localhost:8088/SomeProgram"> <CENTER> First name: running a test server on port 8088 that echoes the data it receives. <INPUT TYPE="TEXT" NAME="firstName" VALUE="J. Random"><BR> Last name: <INPUT TYPE="TEXT" NAME="lastName" VALUE="Hacker"><P> <INPUT TYPE="SUBMIT"> <!-- Press this to submit form --> </CENTER> </FORM> </BODY></HTML> See CSAJSP/2 Ch. 19 for details on forms 8
Background image of page 3

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

View Full DocumentRight Arrow Icon
Aside: Installing HTML Files HTML files do not go in src They go in WebContent
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.

This note was uploaded on 05/13/2011 for the course CSE 474 taught by Professor Ömerkorçak during the Spring '11 term at Marmara Üniversitesi.

Page1 / 23

03-Form-Data - 2010 Marty Hall Originals of Slides and Source Code for Examples http/courses.coreservlets.com/Course-Materials/csajsp2.html

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