use of jaxb1.Catalog in project Payara by payara.
the class Jaxb1MarshallingTestServlet method service.
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("text/html;charset=UTF-8");
PrintWriter out = resp.getWriter();
out.println("jaxb1 marshalling test: ");
try {
JAXBContext jc = JAXBContext.newInstance("jaxb1");
Marshaller m = jc.createMarshaller();
ObjectFactory of = new ObjectFactory();
Catalog c = of.createCatalog();
c.setSection("jaxb1 section");
StringWriter sw = new StringWriter();
m.marshal(c, sw);
String s = sw.toString();
if (s.contains("<catalog section=\"jaxb1 section\"/>"))
out.println("marshalled OK");
else {
out.println("jaxb1 marshalling failed");
System.err.println("Error in Jaxb1MarshallingTestServlet. Marshalling result: " + s);
}
} catch (JAXBException e) {
out.println("jaxb1 marshalling failed: " + e.getMessage());
e.printStackTrace();
}
}
Aggregations