Wednesday 12 March 2014

what is servlet and how and why use servlet ?

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class FetchDataServlet extends HttpServlet{

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {


System.out.println(" call method from html post method");
// now get data from html

String name=req.getParameter("name");
String emi=req.getParameter("email");

System.out.println(" Html data  name ::"+name);
System.out.println(" html data  email :: "+emi);



}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {

System.out.println(" call get method ");

String name=req.getParameter("name");
String emi=req.getParameter("email");

System.out.println(" Html data  name ::"+name);
System.out.println(" html data  email :: "+emi);

}
}



No comments:

Post a Comment