SlideShare una empresa de Scribd logo
1 de 7
03-Handling Requests DhrubojyotiKayal
Form data as client request Creating and submitting HTML forms Reading request parameters Agenda
Need for forms HTML forms  Fields – input text , radio, check box etc Data in these fields come along on button click to submit the form Result of form submission http://domain/empweb/simpleservlet?name=dhrubo&profession=IT&age=31 Form data as client request
<form action=“SimpleServlet“ method=“post”> <center> First name: <input type=“text" name="firstName" value=""><BR> Last name: <input type=“text" name="lastName" value=""> <P> <input type=“submit“> </center> </form> Create & Submit HTML forms
request.getParameter("name") Returns URL-decoded value of first occurrence of name in query string Works identically for GET and POST requests Returns null if no such parameter is in query data request.getParameterValues("name") Returns an array of the URL-decoded values of all occurrences of name in query string Returns a one-element array if param not repeated Returns null if no such parameter is in query request.getParameterNames() or request.getParameterMap() Returns Enumeration or Map of request params Usually reserved for debugging Reading form data
Write a servlet which echoes all the request parameters and their values Excerise
Q&A

Más contenido relacionado

Similar a 03 handling requests

Php Form
Php FormPhp Form
Php Formlotlot
 
Lecture 2 - Comm Lab: Web @ ITP
Lecture 2 - Comm Lab: Web @ ITPLecture 2 - Comm Lab: Web @ ITP
Lecture 2 - Comm Lab: Web @ ITPyucefmerhi
 
Quick Referance to WML
Quick Referance to WMLQuick Referance to WML
Quick Referance to WMLNitin Saswade
 
Getting Interactive: Chapter 14
Getting Interactive: Chapter 14Getting Interactive: Chapter 14
Getting Interactive: Chapter 14Gene Babon
 
Website Integration with QuickBase - Joshua McGinnis
Website Integration with QuickBase - Joshua McGinnisWebsite Integration with QuickBase - Joshua McGinnis
Website Integration with QuickBase - Joshua McGinnisQuickBase, Inc.
 
HTML5 with examples
HTML5 with examplesHTML5 with examples
HTML5 with examplesgopivthmk
 
From "Username and Password" to InfoCard
From "Username and Password" to InfoCardFrom "Username and Password" to InfoCard
From "Username and Password" to InfoCardgoodfriday
 
Html part2
Html part2Html part2
Html part2suba_sqa
 
Html part2 (1)
Html part2 (1)Html part2 (1)
Html part2 (1)suba_sqa
 
KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7phuphax
 
HTML FORMS PPT - JATIN MALHOTRA (1).pptx
HTML FORMS PPT - JATIN MALHOTRA (1).pptxHTML FORMS PPT - JATIN MALHOTRA (1).pptx
HTML FORMS PPT - JATIN MALHOTRA (1).pptxVAIBHAV481101
 
Introduction to Web Design
Introduction to Web DesignIntroduction to Web Design
Introduction to Web Designwebhostingguy
 
Supersize me
Supersize meSupersize me
Supersize medominion
 

Similar a 03 handling requests (20)

Forms 2010
Forms 2010Forms 2010
Forms 2010
 
Php Form
Php FormPhp Form
Php Form
 
Lecture 2 - Comm Lab: Web @ ITP
Lecture 2 - Comm Lab: Web @ ITPLecture 2 - Comm Lab: Web @ ITP
Lecture 2 - Comm Lab: Web @ ITP
 
Quick Referance to WML
Quick Referance to WMLQuick Referance to WML
Quick Referance to WML
 
Getting Interactive: Chapter 14
Getting Interactive: Chapter 14Getting Interactive: Chapter 14
Getting Interactive: Chapter 14
 
Forms
FormsForms
Forms
 
Website Integration with QuickBase - Joshua McGinnis
Website Integration with QuickBase - Joshua McGinnisWebsite Integration with QuickBase - Joshua McGinnis
Website Integration with QuickBase - Joshua McGinnis
 
HTML5 with examples
HTML5 with examplesHTML5 with examples
HTML5 with examples
 
Html5
Html5Html5
Html5
 
Intro Html
Intro HtmlIntro Html
Intro Html
 
From "Username and Password" to InfoCard
From "Username and Password" to InfoCardFrom "Username and Password" to InfoCard
From "Username and Password" to InfoCard
 
Html part2
Html part2Html part2
Html part2
 
Html part2 (1)
Html part2 (1)Html part2 (1)
Html part2 (1)
 
Zend Form Tutorial
Zend Form TutorialZend Form Tutorial
Zend Form Tutorial
 
KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7
 
HTML FORMS PPT - JATIN MALHOTRA (1).pptx
HTML FORMS PPT - JATIN MALHOTRA (1).pptxHTML FORMS PPT - JATIN MALHOTRA (1).pptx
HTML FORMS PPT - JATIN MALHOTRA (1).pptx
 
Introduction to Web Design
Introduction to Web DesignIntroduction to Web Design
Introduction to Web Design
 
Supersize me
Supersize meSupersize me
Supersize me
 
Html forms
Html formsHtml forms
Html forms
 
HTML5 Web Forms
HTML5 Web FormsHTML5 Web Forms
HTML5 Web Forms
 

Más de dhrubo kayal

Más de dhrubo kayal (20)

Cipla 20-09-2010
Cipla   20-09-2010Cipla   20-09-2010
Cipla 20-09-2010
 
01 session tracking
01   session tracking01   session tracking
01 session tracking
 
02 up close with servlets
02 up close with servlets02 up close with servlets
02 up close with servlets
 
01 overview-servlets-and-environment-setup
01 overview-servlets-and-environment-setup01 overview-servlets-and-environment-setup
01 overview-servlets-and-environment-setup
 
19 reflection
19   reflection19   reflection
19 reflection
 
18 concurrency
18   concurrency18   concurrency
18 concurrency
 
17 exceptions
17   exceptions17   exceptions
17 exceptions
 
16 containers
16   containers16   containers
16 containers
 
15 interfaces
15   interfaces15   interfaces
15 interfaces
 
14 initialization & cleanup
14   initialization & cleanup14   initialization & cleanup
14 initialization & cleanup
 
13 inheritance
13   inheritance13   inheritance
13 inheritance
 
12 encapsulation
12   encapsulation12   encapsulation
12 encapsulation
 
11 static
11   static11   static
11 static
 
10 access control
10   access control10   access control
10 access control
 
09 packages
09   packages09   packages
09 packages
 
08 class and object
08   class and object08   class and object
08 class and object
 
07 flow control
07   flow control07   flow control
07 flow control
 
05 operators
05   operators05   operators
05 operators
 
04 data types & variables
04   data types & variables04   data types & variables
04 data types & variables
 
03 hello world with java
03   hello world with java03   hello world with java
03 hello world with java
 

03 handling requests

  • 2. Form data as client request Creating and submitting HTML forms Reading request parameters Agenda
  • 3. Need for forms HTML forms Fields – input text , radio, check box etc Data in these fields come along on button click to submit the form Result of form submission http://domain/empweb/simpleservlet?name=dhrubo&profession=IT&age=31 Form data as client request
  • 4. <form action=“SimpleServlet“ method=“post”> <center> First name: <input type=“text" name="firstName" value=""><BR> Last name: <input type=“text" name="lastName" value=""> <P> <input type=“submit“> </center> </form> Create & Submit HTML forms
  • 5. request.getParameter("name") Returns URL-decoded value of first occurrence of name in query string Works identically for GET and POST requests Returns null if no such parameter is in query data request.getParameterValues("name") Returns an array of the URL-decoded values of all occurrences of name in query string Returns a one-element array if param not repeated Returns null if no such parameter is in query request.getParameterNames() or request.getParameterMap() Returns Enumeration or Map of request params Usually reserved for debugging Reading form data
  • 6. Write a servlet which echoes all the request parameters and their values Excerise
  • 7. Q&A