Get parameters value from the users
// Get parameters value from the users
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class Servlet2_getparameter extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("<h1>" + req.getParameter("first_name") + "</h1>"
+ "\n" +
"<h1>" + req.getParameter("last_name") + "</h1>");
}
}
//HTML FILE.
<form action="http://localhost/servlet/Servlet2_getparameter" method="get">
First Name : <input type="Text" name="first_name"><br><br>
Last Name : <input type="Text" name="last_name"><br><br>
<input type="submit" name="sb" value="submit">
</form>
Comments
Post a Comment