|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| package examples; |
|
17 |
| |
|
18 |
| import javax.servlet.jsp.*; |
|
19 |
| import javax.servlet.jsp.tagext.*; |
|
20 |
| import java.util.Hashtable; |
|
21 |
| import java.io.Writer; |
|
22 |
| import java.io.IOException; |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| public class FooTag |
|
32 |
| extends ExampleTagBase |
|
33 |
| { |
|
34 |
| private String atts[] = new String[3]; |
|
35 |
| int i = 0; |
|
36 |
| |
|
37 |
0
| private final void setAtt(int index, String value) {
|
|
38 |
0
| atts[index] = value;
|
|
39 |
| } |
|
40 |
| |
|
41 |
0
| public void setAtt1(String value) {
|
|
42 |
0
| setAtt(0, value);
|
|
43 |
| } |
|
44 |
| |
|
45 |
0
| public void setAtt2(String value) {
|
|
46 |
0
| setAtt(1, value);
|
|
47 |
| } |
|
48 |
| |
|
49 |
0
| public void setAtt3(String value) {
|
|
50 |
0
| setAtt(2, value);
|
|
51 |
| } |
|
52 |
| |
|
53 |
| |
|
54 |
| |
|
55 |
| |
|
56 |
| |
|
57 |
| |
|
58 |
0
| public int doStartTag() throws JspException {
|
|
59 |
0
| i = 0;
|
|
60 |
0
| return EVAL_BODY_TAG;
|
|
61 |
| } |
|
62 |
| |
|
63 |
0
| public void doInitBody() throws JspException {
|
|
64 |
0
| pageContext.setAttribute("member", atts[i]);
|
|
65 |
0
| i++;
|
|
66 |
| } |
|
67 |
| |
|
68 |
0
| public int doAfterBody() throws JspException {
|
|
69 |
0
| try {
|
|
70 |
0
| if (i == 3) {
|
|
71 |
0
| bodyOut.writeOut(bodyOut.getEnclosingWriter());
|
|
72 |
0
| return SKIP_BODY;
|
|
73 |
| } else |
|
74 |
0
| pageContext.setAttribute("member", atts[i]);
|
|
75 |
0
| i++;
|
|
76 |
0
| return EVAL_BODY_TAG;
|
|
77 |
| } catch (IOException ex) { |
|
78 |
0
| throw new JspTagException(ex.toString());
|
|
79 |
| } |
|
80 |
| } |
|
81 |
| } |
|
82 |
| |