package servlet;

import java.io.IOException;
import java.io.PrintWriter;

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

import ejb.EJBNoInterfaceBean;

/**
 * Servlet implementation class EJBHelloServlet
 */
@WebServlet(description = "EJBHelloServlet", urlPatterns = { "/EJBHelloServlet" })
public class EJBHelloServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;
	@EJB(mappedName = "EJBNoInterfaceBean/no-interface")
	EJBNoInterfaceBean eJBNoInterfaceBean;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public EJBHelloServlet() {
		super();

	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		PrintWriter out = response.getWriter();

		try {
			out.println(eJBNoInterfaceBean.ejb3_1HelloWorld("using JBoss 6 Application server"));
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
