request.getParameter() can be used for both Get & Post Method

Discussions

EJB design: request.getParameter() can be used for both Get & Post Method

  1. I am hitting a servlet like below
    <form method="GET" Action="/abc?filingId=1" .....>
    </Form>

    but in abc servlet, request.getParameter("filingId") is sets null value, but when i change the method from get to post, it works fine.

    Thanks, any explaination of two methods.
    fa.
  2. Hi
     Both these methods serve the same purpose. If you are using POST method the form action should be POST where as when u r using GET method the form action should be GET.
     The difference between the POST and GET is that Get sends data in a QUERY_STRING variable which is 255 characters to 1024 characters depends on the browser. It truncates the data after the length exceeds 1024 charcters. Where as POST method there is no limit you can send objects.
    when u use GET method u can see the QUERY_STRING in the browser address bar and in POST u cannot see that. You can use any of these methods. The QUERY_STRING is encryted when u use GET method. In the HTML form
    <form name="frm" action="someclass" method="get" enctype="application/www-urlencoded">

    Bye
    Asad
  3. I think you are writing request.getParameter() from doPost method. It should be from doGet method.