KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cowsultants > itracker > web > taglib > ClearErrorsTag


1 /*
2  * This software was designed and created by Jason Carroll.
3  * Copyright (c) 2002, 2003, 2004 Jason Carroll.
4  * The author can be reached at jcarroll@cowsultants.com
5  * ITracker website: http://www.cowsultants.com
6  * ITracker forums: http://www.cowsultants.com/phpBB/index.php
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it only under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  */

18
19 package cowsultants.itracker.web.taglib;
20
21 import javax.servlet.*;
22 import javax.servlet.http.*;
23 import javax.servlet.jsp.JspException JavaDoc;
24 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
25
26 import org.apache.struts.Globals;
27 import org.apache.struts.action.*;
28
29 public final class ClearErrorsTag extends TagSupport JavaDoc {
30     private String JavaDoc name = Globals.ERROR_KEY;
31
32     public String JavaDoc getName() {
33         return name;
34     }
35
36     public void setName(String JavaDoc value) {
37         name = value;
38     }
39
40     public int doStartTag() throws JspException JavaDoc {
41           return (SKIP_BODY);
42     }
43
44     public int doEndTag() throws JspException JavaDoc {
45         ActionErrors errors = null;
46           HttpSession session = pageContext.getSession();
47
48         if(session == null) {
49             return EVAL_PAGE;
50         }
51
52         try {
53             session.removeAttribute(getName());
54         } catch(ClassCastException JavaDoc cce) {
55         }
56         return EVAL_PAGE;
57     }
58
59     public void release() {
60         super.release();
61         name = Globals.ERROR_KEY;
62     }
63 }
64
Popular Tags