users@jersey.java.net

Re: [Jersey] Is HttpServletRequest always null using HttpServer?

From: Zach Cox <zcox522_at_gmail.com>
Date: Thu, 15 May 2008 07:33:25 -0400

As a Jersey user I would say logging a warning if a null
HttpServletRequest (or other object) is injected would really help.

Thanks,
Zach


On Thu, May 15, 2008 at 6:58 AM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:
> Marc Hadley wrote:
>>
>> On May 14, 2008, at 1:33 PM, Zach Cox wrote:
>>
>>> I'm new to Jersey, just playing around to learn more (using 0.8). I'm
>>> currently just using the simple HttpServer to launch my little test
>>> app:
>>>
>>> HttpServer server = HttpServerFactory.create("http://localhost:9998/");
>>> server.start();
>>>
>>> I then have a resource class that gets a HttpServletRequest field
>>> injected:
>>>
>>> @Path("something")
>>> public class MyResource
>>> {
>>> @Context
>>> HttpServletRequest request;
>>> }
>>>
>>> That request field is always null. Is this just an effect of using
>>> HttpServer and not using a proper container like Jetty or Tomcat? Or
>>> am I doing something wrong?
>>>
>> As you guessed, HttpServletRequest is only available when running in a
>> Servlet container.
>>
>
> Should Jersey throw an exception and not deploy in such cases or should it
> log a warning instead?
>
> Paul.
>
> --
> | ? + ? = To question
> ----------------\
> Paul Sandoz
> x38109
> +33-4-76188109
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>