Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
16.2 The FORM Element
391
not return results (e.g., for accepting orders for products). You must use 
the 
POST
 method (see 
METHOD
 in the following subsection) when using a 
mailto
 URL. 
METHOD
The 
METHOD
 attribute specifies how the data will be transmitted to the 
HTTP server. When 
GET
 is used, the data is appended to the end of 
the designated URL after a question mark. For an example, see Sec 
tion 16.1 (How HTML Forms Transmit Data). 
GET
 is the default and is 
also the method that is used when a browser requests a normal URL. 
When 
POST
 is used, the data is sent on a separate line. 
The advantages of using the 
GET
 method are twofold: the method is 
simple; and with servlets that use 
GET
, users can access those servlets 
for testing and debugging without creating a form, simply by entering 
a URL with the proper data appended. On the other hand, due to 
URL size restrictions on some browsers, 
GET
 requests have limits on 
the amount of data that can be appended, whereas 
POST
 requests do 
not. Another disadvantage of 
GET
 is that most browsers show the URL, 
including the attached data string, in an address field at the top of the 
browser. This display makes 
GET
 inappropriate for sending sensitive 
data if your computer is in a relatively public place.
ENCTYPE
This attribute specifies the way in which the data will be encoded 
before being transmitted. The default is 
applica 
tion/x www form urlencoded
, which means that the client converts 
each space into a plus sign (+) and every other nonalphanumeric char 
acter into a percent sign (%) followed by the two hexadecimal digits 
representing that character (e.g., in ASCII or ISO Latin 1). Those 
transformations are in addition to placing an equal sign (
=
) between 
entry names and values and an ampersand (
&
) between entries. 
For example, Figure 16 5 shows a version of the 
GetForm.html
 page 
(Listing 16.1) where  
Marty (Java Hacker?)
  is entered for the first 
name. As can be seen in Figure 16 6, this entry gets sent as 
Marty+%28Java+Hacker%3F%29
 . That's because spaces become plus 
signs, 28 is the ASCII value (in hex) for a left parenthesis, 3F is the 
ASCII value of a question mark, and 29 is a right parenthesis.
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved