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...

 





Getting the Client's Address in a Servlet


public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    // Get client's IP address
    String addr = req.getRemoteAddr(); // 110.103.113.113

    // Get client's hostname
    String host = req.getRemoteHost(); //java.com
}