That method is introduced since Servlet 3.0. So, it's only available if you configure and develop your project against a Servlet 3.0 compatible container such as Glassfish 3.x.
However, you seem to already have Glassfish 3.x. Then there are other possible causes for this particular problem, given that you're developing in Eclipse:
Glassfish isn't been associated as project's target runtime. In project's properties, make sure it's been selected in Targeted Runtimes section. This way Eclipse will automagically include its libraries in the project's buildpath.

Project isn't been configured as Servlet 3.0 project. In project's properties, make sure Dynamic Web Module version is set to 3.0 in Project Facets section. This way Eclipse will automagically build against version 3.0 instead of a lower one.

You've manually downloaded arbitrary javaee.jar and/or servlet-api.jar files of a completely different servletcontainer version and placed it in project's buildpath/classpath via /WEB-INF/lib which is getting precedence over Glassfish's own libraries. This is utterly wrong. You should not do that. Undo all those changes. This is unnecessary if you properly specify the server as targeted runtime.
See also: