IntelliJ Java IDE
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes getParameter() in HttpServlet Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "getParameter() in HttpServlet" Watch "getParameter() in HttpServlet" New topic
Author

getParameter() in HttpServlet

Roland Berger
Greenhorn

Joined: Feb 05, 2002
Posts: 1
Hi all
When I use a HTML Form using the POST methode I can not get the parameter name and value from an input field with . Only with I can read the information.
Is that right or am I doing something wrong?
Thanks
Roland
Axel Janssen
Ranch Hand

Joined: Jan 08, 2001
Posts: 2164
Hi Roland,
you can use with post and get:
-HttpServletRequest.getParameter(String fieldName);
-HttpServletRequest.getParameterNames();
Returns an Enumeration of String objects containing the names of the parameters contained in this request.
- HttpServletRequest.getParameterValues(String fieldName)
Returns an array of String objects containing all of the values the given request parameter has, or null if the parameter does not exist.
You find more detailled informations here:
http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/ServletRequest.html.
These methods are FAR more common and easy to use than the getInputStream().
No time to test now, but I strongly believe that the request.getInputStream() works only with doPost(). Not with doGet(). We had a discussion in this forum some time ago about the very similar getReader method.
http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=18&t=000755
regards axel

[ February 05, 2002: Message edited by: Axel Janssen ]
 
 
subject: getParameter() in HttpServlet
 
Threads others viewed
how to avoid many if else [Pojo Validation]
editable JCombobox need help getting text from user
Place like JavaRanch for Psychologists
Length Converter Calc
Can two different web application share a variable
IntelliJ Java IDE