Java Reference
In-Depth Information
com.packtpub.wflydevelopment.chapter2 as the package name. This is
shown in the following screenshot:
The wizard will generate a basic servlet skeleton that needs to be enhanced with the fol-
lowing set of code lines:
@WebServlet("/test")
public class TestServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final String CONTENT_TYPE =
"text/html;charset=UTF-8";
private static final String MESSAGE = "<!DOCTYPE
html><html>" +
"<head><title>Hello!</title></head>" +
"<body>Hello World WildFly</body>" +
"</html>";
@Override
protected void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
try (PrintWriter out = response.getWriter()) {
out.println(MESSAGE);
}
}
}
Search WWH ::




Custom Search