dev@grizzly.java.net

Re: How to return a different response status

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Fri, 01 Jun 2007 11:47:36 -0400

James Lorenzen wrote:
> OK I will thanks.
>
> Previously we were doing this in our afterService. Do I still need
> request.action(...)
>
> public void afterService(Request request, Response response)
> throws Exception {
> request.action(ActionCode.ACTION_POST_REQUEST, null);
> }

No no need in that case. This call can be moved to the service method
instead.

>
> BTW, can you guys make some public javadocs? I can't find them anywhere
> and it would really be helpful if the community had them.

Agreed. Yes I need to learn how to do that with Maven 2, which is
probably trivial :-)

-- Jeanfrancois




>
> -----Original Message-----
> From: Jeanfrancois.Arcand_at_Sun.COM [mailto:Jeanfrancois.Arcand_at_Sun.COM]
> Sent: Friday, June 01, 2007 10:32 AM
> To: James Lorenzen
> Cc: dev_at_grizzly.dev.java.net; Chad Gallemore
> Subject: Re: How to return a different response status
>
>
>
> James Lorenzen wrote:
>> POST
>
>
>
>> -----Original Message-----
>> From: Jeanfrancois.Arcand_at_Sun.COM [mailto:Jeanfrancois.Arcand_at_Sun.COM]
>
>> Sent: Thursday, May 31, 2007 5:16 PM
>> To: dev_at_grizzly.dev.java.net
>> Cc: Chad Gallemore; James Lorenzen
>> Subject: Re: How to return a different response status
>>
>> Hi,
>>
>> James Lorenzen wrote:
>>> I am using Grizzly in a simple way to process HTTP GET requests for
> an
>>> RSS Reader.
>>>
>>> However I am trying to set the response status for different events.
>>> Unfortunately this doesn't work.
>>>
>>>
>>>
>>> public void service(final Request request, final Response response)
>>> throws Exception {
>>>
>>> if (!request.method().toString().equalsIgnoreCase("GET")) {
>>>
>>> response.setStatus(HttpURLConnection.HTTP_BAD_METHOD);
>>>
>>> response.finish();
>
> Remove the response.finish() and do, in afterService(Req,res):
>
>> public void afterService(Request req, Response res)
>> throws Exception {
>> // Recycle the wrapper request and response
>> req.recycle();
>> res.recycle();
>> }
>
> Thanks will works.
>
> -- Jeanfrancois
>
>
>>> return;
>>>
>>> }
>>>
>>>
>>>
>>> When this starts up and I send a POST request I expect a 405, but
> that
>>> doesn't happen. What am I doing wrong?
>> When you do a POST, what request.method().toString() return?
>>
>> Thanks
>>
>> -- Jeanfrancois
>>
>>
>>
>>
>>