protected void service(HttpServletRequest req,
HttpServletResponse res) throws IOException, ServletException {
try {
Context ctx = new InitialContext();
MagicGBallLocalHome ejbHome = (MagicGBallLocalHome) ctx.lookup("java:comp/env/mGball");
MagicGBallLocal m8ball = ejbHome.create();
String question = req.getParameter("question");
String answer = m8ball.ask(question);
PrintWriter out = res.getWriter();
out.print(answer);
} catch (NamingException e) {
e.printStackTrace();
} catch (CreateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
|