Java Reference
In-Depth Information
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, Object> headers,
OutputStream out) throws IOException {
System.out.println("writeTo");
out.write(ORDER_HTML_FORM.getBytes());
if (products.isEmpty()) {
out.write(ORDER_EMPTY_HEADER.getBytes());
} else {
//there are items in order; show table of them
out.write(String.format(
ITEMS_HEADER, products.size()).getBytes());
for (Product p : products) {
out.write("<tr><td>".getBytes());
out.write(p.getId().getBytes());
out.write("</td><td>".getBytes());
out.write(p.getName().getBytes());
out.write("</td>".getBytes());
out.write("<td>".getBytes());
out.write(Integer.toString(p.getQty()).getBytes());
out.write("</td></tr>".getBytes());
}
out.write("</table></form>".getBytes());
}
out.write(END_HTML.getBytes());
}
private static String ORDER_HTML_FORM =
"<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01
Transitional//EN'>\n" +
"<html><head><title>Order Form</title></head>" +
"<body><h1>Supply Chain Order Form:</h1>" +
"<form name='order' action='order' method='POST'>" +
"<table><tr>" +
"<td align='left'>ID:</td>" +
"<td><input type='text' name='id' value='' size='20' /></td>" +
"</tr><tr>" +
"<td align='left'>Product Name:</td>\n" +
"<td><input type='text' name='name' value='' size='20' /></td>"
+
"</tr><tr>" +
"<td align='left'>Quantity:</td>" +
"<td><select name='qty' value='' />" +
Search WWH ::




Custom Search