01: /**
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 2006 Bull S.A.S
04: * Contact: jonas-team@objectweb.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19: * USA
20: *
21: * --------------------------------------------------------------------------
22: * $Id: ExceptionServlet.java 8229 2006-04-11 08:03:19Z pelletib $
23: * --------------------------------------------------------------------------
24: */package org.objectweb.sampleCluster2.web;
25:
26: import java.io.IOException;
27:
28: import javax.servlet.RequestDispatcher;
29: import javax.servlet.ServletException;
30: import javax.servlet.http.HttpServletRequest;
31: import javax.servlet.http.HttpServletResponse;
32:
33: import org.objectweb.sampleCluster2.ejb.MyEjb1;
34: import org.objectweb.sampleCluster2.ejb.MyException;
35:
36: /**
37: * @author goebelg Release an http session servlet
38: */
39: public class ExceptionServlet extends AbstractServlet {
40:
41: /**
42: *
43: */
44: private static final long serialVersionUID = 1L;
45:
46: /**
47: * doGet methode of the servlet
48: * @param req http servlet request
49: * @param res http servlet response
50: * @throws ServletException servlet exception
51: * @throws IOException io exception
52: */
53: public void doGet(HttpServletRequest req, HttpServletResponse res)
54: throws ServletException, IOException {
55:
56: // creating a new stateless EJB -> EJBCreate
57: MyEjb1 bean = theEJB();
58: try {
59: bean.throwMyException();
60: } catch (MyException e) {
61: System.out.println("My Exception caught" + e);
62: e.printStackTrace();
63: req.setAttribute("expectedException", "OK");
64: req.setAttribute("exception", e);
65: } catch (Exception e) {
66: System.out.println("Exception caught" + e);
67: e.printStackTrace();
68: req.setAttribute("expectedException", "KO");
69: req.setAttribute("exception", e);
70: }
71:
72: RequestDispatcher disp = req
73: .getRequestDispatcher("../jsp/exceptionRsp.jsp");
74: disp.forward(req, res);
75:
76: return;
77: }
78: }
|