KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > j2biz > blogunity > web > actions > blog > ErrorAction


1 /*
2  * $Id: ErrorAction.java,v 1.1 2005/01/09 12:26:48 michelson Exp $
3  *
4  * Copyright (c) 2005 j2biz Group, http://www.j2biz.com Koeln / Duesseldorf ,
5  * Germany
6  *
7  * @author Max Kalina
8  *
9  *
10  * This program is free software; you can redistribute it and/or modify it under
11  * the terms of the GNU General Public License as published by the Free Software
12  * Foundation; either version 2 of the License, or (at your option) any later
13  * version.
14  *
15  * This program is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License along with
21  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22  * Place, Suite 330, Boston, MA 02111-1307 USA
23  *
24  */

25
26 package com.j2biz.blogunity.web.actions.blog;
27
28 import javax.servlet.http.HttpServletRequest JavaDoc;
29 import javax.servlet.http.HttpServletResponse JavaDoc;
30
31 import org.apache.commons.lang.exception.ExceptionUtils;
32
33 import com.j2biz.blogunity.exception.BlogunityException;
34 import com.j2biz.blogunity.web.ActionResultFactory;
35 import com.j2biz.blogunity.web.IActionResult;
36 import com.j2biz.blogunity.web.actions.AbstractAction;
37
38 public class ErrorAction extends AbstractAction {
39
40     private static final IActionResult ERROR_FORWARD = ActionResultFactory
41             .buildForward("/errorView.vm");
42
43     private String JavaDoc blogname;
44
45     private Throwable JavaDoc throwable;
46
47     public ErrorAction(String JavaDoc blogname) {
48         this(blogname, null);
49     }
50
51     public ErrorAction(String JavaDoc blogname, Throwable JavaDoc throwable) {
52         this.blogname = blogname;
53         this.throwable = throwable;
54     }
55
56     /*
57      * (non-Javadoc)
58      *
59      * @see com.j2biz.blogunity.web.actions.AbstractAction#execute(javax.servlet.http.HttpServletRequest,
60      * javax.servlet.http.HttpServletResponse)
61      */

62     public IActionResult execute(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
63             throws BlogunityException {
64
65         if (throwable != null) {
66             request.setAttribute("errorMsg", throwable.getMessage());
67             request.setAttribute("errorStack", ExceptionUtils.getFullStackTrace(throwable));
68         }
69
70         return ERROR_FORWARD;
71
72     }
73
74 }
Popular Tags