Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
3.3 Example: Reading Three Explicit Parameters
67
Core Warning
The values supplied to 
getParameter
 and 
getParameterValues
are case sensitive.
Finally, although most real servlets look for a specific set of parameter
names, for debugging purposes it is sometimes useful to get a full list. Use
getParameterNames
 to get this list in the form of an 
Enumeration
, each
entry of which can be cast to a 
String
 and used in a 
getParameter
 or 
get 
ParameterValues
 call. Just note that the 
HttpServletRequest
 API
does not specify the order in which the names appear within that 
Enumer 
ation
. 
Core Warning
Don't count on 
getParameterNames
 returning the names in any 
particular order.
3.3 Example: Reading Three 
Explicit Parameters
Listing 3.1 presents a simple servlet called 
ThreeParams
 that reads form
data parameters named 
param1
, 
param2
, and 
param3
 and places their val 
ues in a bulleted list. Listing 3.2 shows an HTML form that collects user
input and sends it to this servlet. By use of an 
ACTION
 of 
/servlet/core 
servlets.ThreeParams
, the form can be installed anywhere on the system
running the servlet; there need not be any particular association between the
directory containing the form and the servlet installation directory. Recall
that the specific locations for installing HTML files vary from server to
server. With the JSWDK 1.0.1 and Tomcat 3.0, HTML pages are placed
somewhere in 
install_dir/webpages
 and are accessed via
http://host/path/file.html
. For example, if the form shown in Listing
3.2 is placed in 
install_dir/webpages/forms/ThreeParams 
Form.html
 and the server is accessed from the same host that it is running
on, the form would be accessed by a URL of 
http://local 
host/forms/ThreeParamsForm.html
.
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