Over a million developers have joined DZone.

Minimal Java Servlet

DZone's Guide to

Minimal Java Servlet

Free Resource
There is nothing particularly original here -- there are variations of this all over the place. This works nicely with my JettyLauncher class (see my other posts on DZone Snippets).

package com.babblemind;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class HelloWorldServlet extends HttpServlet{
    protected void doGet(HttpServletRequest httpServletRequest,
	HttpServletResponse httpServletResponse)
	    throws ServletException, IOException {

        PrintWriter out = httpServletResponse.getWriter();
        out.println("Hello World!");

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}