Description:
doGet () method is not secured method. A GET request results from a normal request for a URL or from an HTML form that has no METHOD specified and it should be handled by doGet() method.
Learn through my videos:

Program:
<html>
<body>
<form action=Addmethod=get>
Enter 1:<input type="text" name="no1" ><br>
Enter 2:<input type="text" name="no2" ><br>
<input type="submit" value="submit">
</form>
</body>
</html>
import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet(urlPatterns={/Add}) public class Add extends HttpServlet { public void doPost(HttpServletRequest req, HttpServletResponse res) { processRequest(req,res); } public void doGet(HttpServletRequest req, HttpServletResponse res) { processRequest(req,res); } public void procesRequest(HttpServletRequest req, HttpServletResponse res)throws IOException { int i=Integer.parseInt(req.getParameter(t1)); int j= Integer.parseInt(req.getParameter(t2)); int k=i + j; PrintWriter out =res.getWriter(); out.println(k); } }
Output:

Enter 1:
Enter 2:
Logic:
doGet() method is not secure when passing data to server for e.g password or sensitive information ,instead use doPost().