Wrox Home  
Search P2P Archive for: Go

  Return to Index  

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


Message #1 by "Nikolas Sakic" <beelzabeb@c...> on Mon, 3 Jun 2002 23:40:14
Hello,
   Aside from the parameters in your doXXX methods, your  WEB-INF
directory, you should have web.xml file as well, and the context of that
file should be:


<?xml version="1.0" encoding="ISO-8859-1"?>
 
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
 
<web-app>
<sevlet>
<servlet-name>HelloWorldExample</servlet-name>
<servlet-class>HelloWorldExample</servlet-class>
</web-app>                            







> Hi Linda,

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

> The working is therefore:
i> mport java.io.*;
i> mport java.text.*;
i> mport java.util.*;
i> mport javax.servlet.*;
i> mport javax.servlet.http.*; 

> public class HelloWorldExample extends HttpServlet
{> 

> public void doGet(HttpServletRequest request, HttpServletResponse 
r> esponse)
 >    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 
r> esponse)
 >    throws IOException,  ServletException {
 >        doGet(request,response);
 >    }
}> 

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

  Return to Index