• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getParameter() in HttpServlet

 
Roland Berger
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic