You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.asciidoc
+34-14Lines changed: 34 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -21,8 +21,9 @@ Servlet
21
21
Persistence
22
22
-----------
23
23
24
-
* Right-click on project, select ``Properties'', search for ``facet'', enable ``JPA'', click on ``Apply'', talk about ``Further configuration available'' and default data source
25
-
* Create a new entity `Student`
24
+
* Right-click on project, select ``Properties'', search for ``facet'', enable ``JPA'', click on ``Apply''
25
+
** Talk about ``Further configuration available'' and default data source (no configuration required)
26
+
* Right-click on project, select ``New'', ``JPA Entity'' and give the name as `Student`
26
27
* Add a primary key in the wizard. Use `long` datatype and `id` name.
27
28
* Generate Getter/Setter by clicking ``Source'', ``Getters and Setters''.
28
29
* Add `toString` implementation
@@ -97,6 +98,7 @@ RESTful Web Services
97
98
--------------------
98
99
99
100
* Create a JAX-RS resource `StudentEndpoint`
101
+
**`rest.RestApplication` is added and specifies the base URI for REST resoures as `/rest`.
100
102
** Use `Student` entity as the basis, select `create`, `findById`, `listAll` methods to be generated.
101
103
* Add `@XmlRootElement` in `Student` entity to enable XML <-> Java conversion.
102
104
* Add `@NamedQuery(name="findAllStudents", query="select s from Student s")` to `Student` to enable querying all students.
@@ -142,30 +144,22 @@ public class StudentEndpoint {
142
144
----
143
145
+
144
146
* Use ``Advanced REST Client'' in Chrome
145
-
** Make a GET request
147
+
** Make a GET request to http://localhost:8080/EclipseCon/rest/students
146
148
*** Add Accept: application/xml
147
149
*** Show empty response
148
150
** Make a POST request
149
151
*** Payload as `1`
150
152
***``Content-Type'' header to `text/plain`
151
153
** Make a GET request to validate the data is posted
152
-
** Change `create` method to add Bean Validation constraint
153
-
+
154
-
[source,java]
155
-
----
156
-
public void create(@Min(10) final long id) {
157
-
----
158
-
+
159
-
** Make a POST request with payload as `1` and show an error is being received
160
-
* Edit `doGet` of `TestServlet to match the code given below
154
+
* Edit `doGet` of `TestServlet` to match the code given below
161
155
+
162
156
[source,java]
163
157
----
164
158
ServletOutputStream out = response.getOutputStream();
0 commit comments