Getting a Request Parameter in a JSP Page

In a GET request, the request parameters are taken from the query string . For example, the URL http://javamagics.blogspot.com?param1=v1&param2=v2 contains two request parameters – param1and param2. In a POST request, the request parameters are taken from both query string and the posted data which is encoded in the body of the request.
<%= request.getParameter("name") %>
 Eg:
<%
    if (request.getParameter("name") == null) {
        out.println("Please enter your name.");
    } else {
        out.println("Hi, "+request.getParameter(i)+"...");
    }
%>
If the page was accessed with the URL: http://javamagics.blogspot.com?name=Jerry
the resulting output would be: 
Hi,Jerry... 
If name is not specified on the query string, the output would be: 
Hi,null...

 





2 comments:

Anonymous said...
This comment has been removed by the author.
Web Hosting Services said...

Your blog has given me that thing which I never expect to get from all over the websites. Nice post guys!

Post a Comment