Dear Stackoverflow user,
Could anyone give me an simple example of restful webservice with 2 or more @get and @put in netbeans? Any simple plain text example is sufficient. And it should not include any database!
I would be very glad if some one could help me.
I tried something but it didn’t work out, here’s the code
@Path("/simple")
public class SimpleResource_1 {
@Context
private UriInfo context;
@GET
@Produces("text/plain")
public String getText() {
return "hello world";
}
@Path("/simple/simple1")
public class SimpleResource_11 {
@Context
private UriInfo context;
@GET
@Produces("text/plain")
public String getText1(){
return "hi";
}
}
I get runtime error with this code, though there aren’t any compilation error.
Am i doing it right? or is there something i am missing!!
Thanx a ton in advance!
Cheers!
Assuming you are using the default Netbeans server stack and are thus using
javax.ws.rs:You should only have one public class per Java file. Netbeans should sort out the required imports for the code above if you have created a standard web service project. If you wanted to add a
@PUTyou just add another method to the resource and annotate it appropriately.