How to read request parameters passed in URL using JSP?

JSPJava 8Object Oriented ProgrammingProgramming

The following URL will pass two values to HelloForm program using the GET method.


Below is the main.jsp JSP program to handle input given by web browser. We are going to use the getParameter() method which makes it very easy to access the passed information −

      <title>Using GET Method to Read Form Data</title>
      <h1>Using GET Method to Read Form Data</h1>
         <li><p><b>First Name:</b>
            <%= request.getParameter("first_name")%>
         <li><p><b>Last Name:</b>
            <%= request.getParameter("last_name")%>

Now type href="http://localhost:8080/main.jsp?first_name=ZARA&last_name=ALI" in your browser's Location:box. This will generate the following result −

Using GET Method to Read Form Data

  • First Name: ZARA

  • Last Name: ALI

Updated on 30-Jul-2019 22:30:25