Wrox Home  
Search P2P Archive for: Go

  Return to Index  

servlets thread: Newbie: HTTP method GET is not supported by this URL


Message #1 by linda.postniece@s... on Mon, 1 Apr 2002 08:43:45
Hi Linda,

The "request" parameter of both the doGet & doPost methods
in your servlet is wrong. It must be of the type:
"HttpServletRequest" and not "HttpServlet".

The working is therefore:
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*; 

public class HelloWorldExample extends HttpServlet
{

public void doGet(HttpServletRequest request, HttpServletResponse 
response)
    throws IOException,  ServletException {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        
        out.println("<html>");
        out.println("<head>My first Servlet</head>");
        out.println("<body><p>Hello World!!!</p></body>");
    }
    
    public void doPost(HttpServletRequest request, HttpServletResponse 
response)
    throws IOException,  ServletException {
        doGet(request,response);
    }
}

regards
 - Henrik Eiriksson (hte@e...).

  Return to Index