I am trying to create my first very simple web app. I am using maven, jetty, restful. I have read some topics about it, but they often go to difficult for complete begginer to fast. And I haven't figured out how to get rid of these two problems as simple as possible.
Later on I try to make the app more complex. But I want to test now, how can I get the time the "request" was submitted to server. And also I want to get the time that it took to get the answer to client. I want to display the info in json format. Is there a simple way to do it? How can I do it?
import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; @Path("sample") public class HelloWorldService { @Path("/helloWorld/{first}/{second}/{third}") @GET @Produces(MediaType.APPLICATION_JSON) public HelloWorld helloWorld(@PathParam("first") String first, @PathParam("second") String second, @PathParam("third") String third) { return new HelloWorld(first, second, third); } }
And also:
public class HelloWorld {
private String first;
private String second;
private String third;
public HelloWorld(String first, String second, String third) {
this.first = first;
this.second = second;
this.third= third;
}
public HelloWorld(String first, String second) {
this.first = first;
this.second = second;
}
public HelloWorld(){
}
public HelloWorld(String first) {
this.first= first;
}
public String getFirst() {
return first;
}
public String getSecond(){
return second;
}
public String getThird(){
return third;
}
}
Thank you! :)