KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > webjmx > tags > InvokeTag


1 /*
2  * Copyright (C) WebJMX.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the WebJMX License version 2.0.
6  * See the terms of the WebJMX License in the documentation provided with this software.
7  */

8 /*
9  * MBeanTag.java
10  *
11  * Created on December 12, 2001, 3:19 PM
12  */

13
14 package org.webjmx.tags;
15
16 import java.io.*;
17 import java.util.*;
18 import javax.servlet.jsp.*;
19 import javax.servlet.jsp.tagext.*;
20
21 /** This tag writes a hidden HTML form input tag to the output stream. The content of the tag should contain an ObjectName within an MBeanServer. This tag can be used within a FormMBean tag instead of specifying the mbean attribute of the FormMBean.
22  *
23  * @author John Aronson
24  */

25 public class InvokeTag extends BodyTagSupport implements JMXTaglibConstants
26 {
27     /** Creates new MBeanTag */
28     public InvokeTag()
29     { }
30
31     /** Process the end tag for this instance.
32      * @throws JspException
33      */

34     public int doEndTag()
35         throws JspException
36     {
37         //read in the mbean name
38
BufferedReader in = new BufferedReader(getBodyContent().getReader());
39         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
40                     
41         try
42         {
43             String JavaDoc line = in.readLine();
44             while(line != null)
45             {
46                 sb.append(line);
47                 line = in.readLine();
48             }
49             if(Boolean.getBoolean(DEBUG_PROP)) pageContext.getServletContext().log("mbean tag body content: " +sb.toString());
50             getBodyContent().clear();
51
52             //convert to a form element
53
sb.insert(0, "\" VALUE=\"");
54             sb.insert(0, TAGLIB_INVOKE);
55             sb.insert(0, "<INPUT TYPE=HIDDEN NAME=\"");
56             sb.append("\">\n");
57
58             //write out the form element
59
pageContext.getOut().write(sb.toString());
60         }catch(IOException ex) { ex.printStackTrace(); }
61         
62     return (EVAL_BODY_INCLUDE);
63     }
64     
65 }
66
Popular Tags