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,403
  • 13
  • 22

1 Answers1

4

@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

VeKe
  • 9,043
  • 5
  • 61
  • 67