package com.myeclipseide.sci;

import java.io.IOException;

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

@WebServlet("/AnnotatedServlet")
public class AnnotatedServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;

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

	@Override
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		if (request.getParameter("username").equals(
				request.getServletContext().getAttribute("USERNAME"))
				&& request.getParameter("password").equals(
						request.getServletContext().getAttribute("PASSWORD")))
			response.sendRedirect("pages/success.jsp");
		else
			response.sendRedirect("pages/error.jsp");
	}
}
