Sending data to servlet using http get method

Gererally http get is used to get information from server, but for getting specific information based on id or user name or based on query string we send id,user name or search term query to server.

Here we have created a form tag and two text box to take input age and name from user.
<form action=”SubmitServlet”> is sending data to SubmitServlet.

By default form method is get so it will call doGet() of SubmitServlet.
<form action=”SubmitServlet”> is equivalent to <form action=”SubmitServlet” method=”get”>
While using http get method the submitted content(name and age) is displaying on address bar.

3_project_explor

index.jsp

Enter your name and age

Name :

Age :

SubmitServlet.java

Your detail

Your name :”+name+”

your Age :”+age+”

Result:
Address bar shows http://localhost:8084/ServletTutorial2/SubmitServlet?name=Ram+Kumar&age=22
after ? it is showing submitted data.

3_first

3_second