users@jersey.java.net

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

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 15 May 2008 12:58:10 +0200

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