Re: [jetty-user] Servlet post method is not called in embedded jetty

Shaid <[email protected]> Fri, 18 Mar 2011 13:38:02 -0400
Newsgroups gmane.comp.java.jetty.support
Message-ID <[email protected]>
I forgot to mention that I am using jetty of 6.1.26 version.

Shahid

On Fri, Mar 18, 2011 at 1:36 PM, Shaid <[email protected]> wrote:
> The example servlet works, and its doGet method is called in the
> embedded jetty. But I have issue with doPost method which is not
> getting called. In my project I need to implement doPost method. Below
> is the modified example servlet as:
>
> public class HelloWorld extends HttpServlet
> {
>
>    /* ------------------------------------------------------------ */
>    public void doPost(HttpServletRequest request, HttpServletResponse
> response) throws ServletException, IOException
>    {
>        response.setContentType("text/html");
>        ServletOutputStream out = response.getOutputStream();
>        out.println("<html>");
>        out.println("<h1>Hello World</h1>");
>        out.println("</html>");
>        out.flush();
>
>        try
>        {
>            Thread.sleep(200);
>        }
>        catch (InterruptedException e)
>        {
>            getServletContext().log("exception",e);
>        }
>    }
>
>
> }
>
> When I access the above servlet through the stand alone jetty (non
> embedded mode), running the jetty with the command 'java -jar
> start.jar', the doPost method is called. But with the same servlet
> doPost method is not getting called in the jetty embedded mode.
>
> Shahid
>
>
> On Fri, Mar 18, 2011 at 12:27 PM, Joakim Erdfelt <[email protected]> wrote:
>> You'll want to take a closer look at the embedded examples.
>> Here's a simple example for one servlet.
>> Jetty 6.x
>> - http://svn.codehaus.org/jetty/jetty/branches/jetty-6.1/examples/embedded/src/main/java/org/mortbay/jetty/example/OneServletContext.java
>> Jetty 7.x
>> - http://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/OneServletContext.java
>> The rest of the embedded examples can be found here.
>> Jetty 6.x
>> - http://svn.codehaus.org/jetty/jetty/branches/jetty-6.1/examples/embedded/src/main/java/org/mortbay/jetty/example/
>> Jetty 7.x
>> - http://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/
>> - Joakim
>>
>> On Fri, Mar 18, 2011 at 9:00 AM, Shaid <[email protected]> wrote:
>>>
>>> Servlet post method is getting not called in the embedded jetty. I am
>>> getting the following error as:
>>>
>>> HTTP method GET is not supported by this URL
>>>
>>> The embedded jetty code is:
>>>
>>>         Server server = new Server(8080);
>>>         Context context = new Context(server,"/hello",Context.SESSIONS);
>>>         context.addServlet(new ServletHolder(new HelloWorld()), "/*");
>>>         server.start();
>>>         server.join();
>>>
>>> Can any body help me how to fix this problem?
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>
>>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email