Hi Abhijith,
Yes, It is possible to use doGet()as well as doPost() in a single class.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Test extends HttpServlet throws IOException, ServletException
{
public void doGet(HttpServletRequest req, HttpServletResponse res)
{
doPost(req,res);
} /* end of doget()*/
public void doPost(HttpservletRequest req, HttpServletResponse res)
{
String name=req.getParameter("username");
res.setContentType("text/html");
PrintWriter out= res.getWriter();
out.println(name):
} /*end of dopost*/
} /* end of class */
In your html file the declaration will be like this
form method="Get" action="dosomething".
By looking at get request, the servlet engine will call appropriate class as mapped in web.xml and invokes doget() method, which inturns calls dopost()method.
I think your doubt is clear. If not reply back .
Thanks,
Chandra