Wednesday 12 March 2014

How to call jsp page to servet ??

Index.jsp
Name

email id 






Servlet class
FetchDataServlet.class
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);

}

}



----------------------------------------------------------------------------------------------------------
Servlet and jps coding






No comments:

Post a Comment