Here is the Java source code of a servlet:
import javax.servlet.http. HttpServlet;
import javax.servlet.http. HttpServletRequest;
import javax.servlet.http. HttpServletResponse;
import java.io. IOException;
import java.io. PrintWriter;
import javax.servlet. ServletException;
public class choice extends HttpServlet
{
public void doPost(final HttpServletRequest request,
final HttpServletResponse response)
throws ServletException, IOException
{
final String tChoiceString = request.getParameter("choice");
response.setContentType("text/html");
final PrintWriter tResponsePrintWriter = response.getWriter();
StringBuffer tStringBuffer = new StringBuffer();
tStringBuffer.append("<html>\n" );
tStringBuffer.append("<title>Reply</title>\n" );
tStringBuffer.append("Your choice was: " + tChoiceString + "\n" );
tStringBuffer.append("</html>\n" );
tResponsePrintWriter.println(tStringBuffer);
tResponsePrintWriter.close();
}
}