Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
A.3 Handling the Client Request: Form Data
523
A.3 Handling the Client Request: Form Data
Reading Parameters
  request.getParameter: returns first value
  request.getParameterValues: returns array of all values
Example Servlet
ThreeParams.java
package coreservlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ThreeParams extends HttpServlet {
  public void doGet(HttpServletRequest request,
                    HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String title = "Reading Three Request Parameters";
    out.println(ServletUtilities.headWithTitle(title) +
                "\n" +
                "

" + title + "

\n" +
                "
                "  
  • param1: "
  •                 + request.getParameter("param1") + "\n" +
                    "  
  • param2: "
  •                 + request.getParameter("param2") + "\n" +
                    "  
  • param3: "
  •                 + request.getParameter("param3") + "\n" +
                    "\n" +
                    "");
      }
    }
    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