aspose file tools*
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes can you have both @GET and @POST on same resurce method ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "can you have both @GET and @POST on same resurce method ?" Watch "can you have both @GET and @POST on same resurce method ?" New topic

can you have both @GET and @POST on same resurce method ?

Cosmin Nicolae Vacaroiu
Ranch Hand

Joined: Feb 10, 2011
Posts: 52

I read that you can't/shoudln't because it doesn't conform to the REST principles ..

I mean I know you can have two methods with the same Path and different method designators. But could you on the same method ?
GET should be idempotent, while POST not.

So what's true ? as in all mock tests they say you can.

SCJP 6 (93%), SQL Expert 11g (95%), SCWCD 6 (84%), OCE-EJBD 6 (98%), OCE-JPAD 6 (93%)
Frits Walraven
Creator of Enthuware JWS+ V6

Joined: Apr 07, 2010
Posts: 1529

Hi Cosmin,

The annotations @GET, @POST, @PUT etc are all of the @HttpMethod annotation type, for example @GET:
and the API of @HttpMethod clearly states that:

Annotation Type HttpMethod
Associates the name of a HTTP method with an annotation. A Java method annotated with a runtime annotation that is itself annotated with this annotation will be used to handle HTTP requests of the indicated HTTP method. It is an error for a method to be annotated with more than one annotation that is annotated with HttpMethod.

I agree. Here's the link:
subject: can you have both @GET and @POST on same resurce method ?
Similar Threads
url data into variable
servlet Session
Please Help !! Help needed very urgently
query about GET and POST methods
How can i find out, from where my parameter coming from?