Java
  Home arrow Java arrow Page 6 - Developing JavaServer Pages
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
JAVA

Developing JavaServer Pages
By: Joel Murach
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 64
    2004-05-12


    Table of Contents:
  • Developing JavaServer Pages
  • The Code for the HTML Page that Calls the JSP
  • Imitating HTML
  • How to Create a JSP
  • How to Use the Methods of the Request Object
  • Retrieving Multiple Values
  • How to Request a JSP
  • Using Get and Post Methods
  • Using the Post Method
  • Managing Java Classes
  • Class Location

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Developing JavaServer Pages - Retrieving Multiple Values
    ( Page 6 of 11 )

    To retrieve multiple values for one parameter name, you can use the getParameterValues method as illustrated by the second example. This method is useful for controls like list boxes that allow multiple selections. After you use the getParameterValues method to return an array of String objects, you can use a loop to get the values from the array.

    To get the names of all the parameters sent with a request, you can use the getParameterNames method to return an Enumeration object that contains the names. Then, you can search through the Enumeration object to get the parameter names, and you can use the getParameter method to return the value for each parameter name. This is illustrated by the third example.

    If you're not familiar with the Enumeration class, you can learn more about it though the API. For most purposes, though, you only need to know that an Enumeration object is a collection that can be searched element by element. To determine if more elements exist in the collection, you can use the hasMoreElements method, which returns a boolean value. And to get the next element in the collection, you can use the nextElement method. 

    Where and How to Save a JSP

    As Figure 6 shows, you normally save the JSPs of an application in the same directory that you use for the HTML pages of the application. The difference is that the name for a JSP requires a jsp extension. So if you're using a text editor that's not designed for working with JSPs, you may have to place the filename in quotation marks to make sure the file is saved with the jsp extension.

    Figure 6: Where and how to save a JSP

    Where the Show_email_entry.jsp Page is Saved

    c:tomcatwebappsmurachemail4

    Other Places You Can Save Your JSPs

    c:tomcatwebappsyourDocumentRoot
    c:tomcatwebappsyourDocumentRootyourSubdirectory
    c:tomcatwebappsROOT
    c:tomcatwebappsROOTyourSubdirectory

    A Standard Dialog Box for Saving a JSP

    JavaServer Pages

    Description

    JSPs are normally saved in the same directory as the HTML pages. This directory should be a subdirectory of the web applications directory for your server. If you're running Tomcat on your PC, that directory is usually c:tomcatwebapps or c:jakarta-tomcatwebapps.

    For the first 16 chapters of this book, the document root directory for all applications is the murach directory. As a result, the HTML and JSP files for each application are stored in this directory or one of its subdirectories.

    If you're using Tomcat on your local system, you can also use webappsROOT as the root directory for your applications. The ROOT directory is automatically set up when you install Tomcat, and it is the default document root directory.

    To make sure that the filename for a JSP is saved with the jsp extension when you're using an HTML or text editor, you can enter the filename within quotes.

    Like HTML pages, JSPs must be saved in a directory that's available to the web server. For Tomcat 4.0, you can use any directory under the webapps directory. The root directory for the web applications that are presented in the first 16 chapters of this book is the webappsmurach directory, and the subdirectory for the Email List application that's presented in this chapter is email4. Note, however, that you can also use the webappsROOT directory that Tomcat sets up as the default root directory. Or, you can create your own subdirectories under the webapps directory. 

    Remember: this is from chapter four of Joel Murach's Java Servlets and JSP (Mike Murach & Associates, ISBN 1890774189, 2003). Grab a copy at your favorite book store today!

     Buy this book now.



     
     
    >>> More Java Articles          >>> More By Joel Murach
     

       

    JAVA ARTICLES

    - Exception Handling Techniques in Java
    - More About Multithreading in Java
    - The Basics of Multiple Threads in Java
    - Data Access Using Spring Framework JDBC
    - New Object Initialization in Java
    - Adding Images With iTextSharp
    - Adding Columns With iTextSharp
    - Creating Simple PDF Files With iTextSharp
    - The Spring Framework: Understanding IoC
    - Introducing the Spring Framework
    - Java Classes
    - Completing the Syntactic Comparison of Java ...
    - Syntactic Comparison of Java and C/C++
    - Java Statements
    - Conditionals, Expressions and Other Java Ope...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek