package com.myeclipseide.asynccontext;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet(asyncSupported = true, urlPatterns = "/ResultServlet")
public class ResultServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	

	public ResultServlet() {
	}

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		ServletOutputStream outputStream = response.getOutputStream();
		outputStream.println("<HTML><TITLE>Result Servlet</TITLE></H1> " + "<BODY marginwidth=100 >"
				+ "<H1>Your Results</H1>"
				+ "<hr noshade=noshade />");

		outputStream.println("Hello " + "<b>" + request.getAttribute("name")
				+ "</b>," + "</BR>");
		outputStream.println("Your favorite technology is " + "<b>"
				+ request.getAttribute("myFavTech") + "</b>" + "</BR>");
		outputStream.println("You use the server " + "<b>"
				+ request.getAttribute("myAppServer") + "</b>" + "</BR>");
		outputStream.println("You mentioned that you " + "<b>"
				+ request.getAttribute("myMEUsage") + "</b>"
				+ " used MyEclipse before." + "</BR>");
		outputStream.println("You commented that <b>"
				+ request.getAttribute("myComment") + "</b></BR>");
		outputStream.println("<hr noshade=noshade />");
		outputStream.println("<a href='pages/runnable.jsp'>Try again</a><BR />");
		outputStream.println("<a href='index.html'>Go Home</a>");
		outputStream.println("</BODY></BR>");
		outputStream.println("</HTML>");
		
	}

}
