You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
975 B

  1. /* Beispiel angelehnt an http://www.torsten-horn.de/techdocs/jee-rest.htm */
  2. package verteiltesysteme.rest;
  3. import javax.ws.rs.*;
  4. import javax.ws.rs.core.MediaType;
  5. @Path( RESTToLowerCaseService.webContextPath )
  6. public class RESTToLowerCaseService
  7. {
  8. static final String webContextPath = "/touppercase";
  9. @GET @Produces( MediaType.TEXT_PLAIN )
  10. public String toUpperCasePlain( @QueryParam("input") String input )
  11. {
  12. return "Plain-Text: " + input.toUpperCase();
  13. }
  14. @GET @Produces( MediaType.TEXT_HTML )
  15. public String toUpperCaseHtml( @QueryParam("input") String input )
  16. {
  17. return "<html><title>RESTService</title><body><h2>HTML: " + input.toUpperCase() + "</h2></body></html>";
  18. }
  19. @GET @Produces( MediaType.APPLICATION_JSON )
  20. public String toUpperCaseJson( @QueryParam("input") String input )
  21. {
  22. return "{\n \"type\": \"JSON\",\n \"output\": \"" + input.toUpperCase() + "\"\n}";
  23. }
  24. }