In one of the following i found the following question,
"Consider the following
servlet class
public class MyServlet extends HttpServlet
{
public void doPost (HttpServletRequest req, HttpServletResponse res)
{
PrintWriter out = res.getWriter ();
out.println("<html><body>");
out.println("Servicing Post Method");
out.println("</body></html>");
}
}
User requests the servlet by clicking on the hyperlink of a HTML page given bellow.
<html>
<body>
<a href="/servlet/MyServlet">Get Service</a>
</body>
</html> "
And the anwer the default implementation of Generic Servlet doGet will get called.. I was puzzled and tried the same... see my code below,
HTML
=======
<a href="click">Hey</a>
Servlet
=========
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{
PrintWriter out=response.getWriter();
out.println("Hello...")'
}
I got an exception "HTTP method GET is not supported by this URL"
It would be helpful for me if anyone of you tell me whether am somewhere wrong or the mock exam answer is wrong?