protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
	
		AnswerService as = new AnswerService();
		int questionId = Integer.parseInt(request.getParameter("questionId"));

		for (int i = 1; i <= 5; i++) {
			boolean correct = false;
			try {

				String text = request.getParameter("a" + i);
				if (!text.equals("")) {

					if (request.getParameterValues("check") != null) {
						for (String answer : request
								.getParameterValues("check")) {
							if (Integer.parseInt(answer) == i) {
								correct = true;
							}
						}

					} else if (request.getParameter("radio") != null) {
						if (Integer.parseInt(request.getParameter("radio")) == i) {
							correct = true;
						}
					}
					Answer answer = new Answer();
					answer.setQuestionId(questionId);
					answer.setText(text);
					answer.setCorrect(correct);
					//create answer
					as.createEntity(answer);
				}
			} catch (Exception e) {
				e.printStackTrace();
				Logger.getLogger(AnswerServlet.class).error(e.getMessage());
			}
		}
		request.setAttribute("notifyM", "Possible answers added");
		request.setAttribute("questionId", questionId);
		request.getRequestDispatcher("protected/admin/addQuestion.jsp")
				.forward(request, response);

	}