In the code bellow, any time you make a HTTP post request to your servlet the doPost method is called, but if you do the otherwise an HTTP get request the doGet method is called instead. ;)
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class NewServlet extends HttpServlet
{
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
processRequest(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
processRequest(request, response);
}
public String getServletInfo()
{
return "Short description";
}
}
I Hope this helps, you might try this as well
Try this one
http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/
MeTitus