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.

32 lines
990 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( RESTToUpperCaseService.webContextPath )
  6. public class RESTToUpperCaseService
  7. {
  8. static final String webContextPath = "/touppercase";
  9. @GET
  10. @Produces( MediaType.TEXT_PLAIN )
  11. public String toLowerCasePlain( @QueryParam("input") String input )
  12. {
  13. return "Plain-Text: " + input.toUpperCase();
  14. }
  15. @GET
  16. @Produces( MediaType.TEXT_HTML )
  17. public String toLowerCaseHtml( @QueryParam("input") String input )
  18. {
  19. return "<html><title>RESTService</title><body><h2>HTML: " + input.toUpperCase() + "</h2></body></html>";
  20. }
  21. @GET
  22. @Produces( MediaType.APPLICATION_JSON )
  23. public String toLowerCaseJson( @QueryParam("input") String input )
  24. {
  25. return "{\n \"type\": \"JSON\",\n \"output\": \"" + input.toUpperCase() + "\"\n}";
  26. }
  27. }