2

I am using REST API with spring.is it possible that request arrives from UI/CURL to following API with request parameter null?

 @GET
    @Path(/abc)
    @Produces({ "application/xml", "application/json" })
    Public Users getUsers(@Context HttpServletRequest request)
    {
    someOtherClassMethod(request);
    }

should I put null check for request here or request would always be not null if its arrived here.

NikhilP
  • 1,508
  • 14
  • 23

1 Answers1

5

@Context can be used to inject 12 object instances related to the context of HTTP requests.

It behaves just like the @Inject and @Autowired annotations in Java EE and Spring respectively.

@Context HttpServletRequest request

Here bean is created , and so can never be null

No need of null check

Hope this answers

VedantK
  • 9,728
  • 7
  • 66
  • 71