|
18 | 18 | @WebServlet("/TestServlet")
|
19 | 19 | public class TestServlet extends HttpServlet {
|
20 | 20 | private static final long serialVersionUID = 1L;
|
21 |
| - |
22 |
| - @Inject Greeting greeting; |
23 |
| - |
24 |
| - /** |
25 |
| - * @see HttpServlet#HttpServlet() |
26 |
| - */ |
27 |
| - public TestServlet() { |
28 |
| - super(); |
29 |
| - // TODO Auto-generated constructor stub |
30 |
| - } |
| 21 | + |
| 22 | + @Inject |
| 23 | + Greeting greeting; |
| 24 | + |
| 25 | + /** |
| 26 | + * @see HttpServlet#HttpServlet() |
| 27 | + */ |
| 28 | + public TestServlet() { |
| 29 | + super(); |
| 30 | + // TODO Auto-generated constructor stub |
| 31 | + } |
31 | 32 |
|
32 | 33 | /**
|
33 |
| - * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) |
| 34 | + * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse |
| 35 | + * response) |
34 | 36 | */
|
35 | 37 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
36 | 38 | response.getOutputStream().println(greeting.sayHello());
|
37 |
| - |
| 39 | + |
38 | 40 | ServletOutputStream out = response.getOutputStream();
|
39 | 41 | out.print("Retrieving results ...");
|
40 | 42 | Client client = ClientBuilder.newClient();
|
41 |
| - Student[] result = client |
42 |
| - .target("http://localhost:8080/HelloJavaEE7/rest/students") |
43 |
| - .request() |
44 |
| - .get(Student[].class); |
| 43 | + Student[] result = client.target("http://localhost:8080/HelloJavaEE7/rest/students").request() |
| 44 | + .get(Student[].class); |
45 | 45 | for (Student s : result) {
|
46 | 46 | out.print(s.toString());
|
47 | 47 | }
|
48 | 48 |
|
49 | 49 | }
|
50 | 50 |
|
51 | 51 | /**
|
52 |
| - * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) |
| 52 | + * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse |
| 53 | + * response) |
53 | 54 | */
|
54 |
| - protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
| 55 | + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, |
| 56 | + IOException { |
55 | 57 | doGet(request, response);
|
56 | 58 | }
|
57 | 59 |
|
|
0 commit comments