2 This page won't actually work, as it is simply designed to display jsp syntax highlighting.
4 <%@ page info
="A Page to Test Kate Jsp Syntax Highlighting" language
="java" errorPage
="/test-error-page.jsp"%>
5 <%@ include file
="/include/myglobalvars.jsp"%> --%>
6 <%@ page
import="java.util.*,
9 <%@ taglib uri
="/WEB-INF/lib/si_taglib.tld" prefix
="si"%>
10 <jsp:useBean id=
"aPageBean" scope=
"page" class=
"my.package.MyPageBean"/>
11 <jsp:useBean id=
"aRequestBean" scope=
"request" class=
"my.package.MyRequestBean"/>
13 // We can decipher our expected parameters here.
14 String parm1
= noNull(request
.getParameter(PARAMETER_1
)).trim();
15 String parm2
= noNull(request
.getParameter(PARAMETER_2
)).trim();
16 String parm3
= noNull(request
.getParameter(PARAMETER_3
)).trim();
17 String parm4
= noNull(request
.getParameter(PARAMETER_4
)).trim();
18 String parm5
= noNull(request
.getParameter(PARAMETER_5
)).trim();
20 // A sample collection of Integers to display some code folding.
21 List intList
= getIntList(10);
26 <title>A Sample Jsp
</title>
28 <script language=
"javascript"><!--
30 alert("This is the first javascript example.");
34 alert("This is the second javascript example.");
39 <%-- The top label table
. --%>
40 <table width
="400" cellpadding
="0" cellspacing
="0" border
="0">
42 <td
><font size
="3"><b
>The following parameters were detected
:</b></font
></td
>
46 <%-- Display the parameters which might have been passed
in. --%>
47 <table width
="400" cellpadding
="0" cellspacing
="0" border
="0">
48 <%-- Label
; Actual Parameter String
; Value Detected
--%>
50 <td
><b
>PARAMETER_1
</b></td
>
51 <td align
="center"><%=PARAMETER_1
%></td
>
52 <td align
="right">"
;<%=parm1
%>"
;</td
>
55 <%-- Label
; Actual Parameter String
; Value Detected
--%>
57 <td
><b
>PARAMETER_2
</b></td
>
58 <td align
="center"><%=PARAMETER_2
%></td
>
59 <td align
="right">"
;<%=parm2
%>"
;</td
>
62 <%-- Label
; Actual Parameter String
; Value Detected
--%>
64 <td
><b
>PARAMETER_3
</b></td
>
65 <td align
="center"><%=PARAMETER_3
%></td
>
66 <td align
="right">"
;<%=parm3
%>"
;</td
>
69 <%-- Label
; Actual Parameter String
; Value Detected
--%>
71 <td
><b
>PARAMETER_4
</b></td
>
72 <td align
="center"><%=PARAMETER_4
%></td
>
73 <td align
="right">"
;<%=parm4
%>"
;</td
>
76 <%-- Label
; Actual Parameter String
; Value Detected
--%>
78 <td
><b
>PARAMETER_5
</b></td
>
79 <td align
="center"><%=PARAMETER_5
%></td
>
80 <td align
="right">"
;<%=parm5
%>"
;</td
>
86 <%-- Display our list
of random
Integers (shows code folding
). --%>
87 <table width
="400" cellpadding
="0" cellspacing
="0" border
="0">
89 if (intList
!= null && intList
.size() > 0) {
91 <tr
><td
><b
>Here are the elements
of intList
...</b></td
></tr
>
93 Iterator intListIt
= intList
.iterator();
94 while (intListIt
.hasNext()) {
95 Integer i
= (Integer
) intListIt
.next();
97 <tr
><td
><%=i
.toString()%></td></tr
>
102 <tr
><td
><font color
="blue"><b
><i
>Oooops
, we forgot to initialize intList
!</i></b
></font></td
></tr
>
110 <%-- We can call javascript functions
. --%>
111 <table width
="400" cellpadding
="0" cellspacing
="0" border
="0">
112 <tr
><td colspan
="2"><b
>Test our javascript
...</b></td
></tr
>
114 <td
><input type
="button" name
="button1" value
="Alert 1" onmouseup
="javascript:doAlert1()"></td
>
115 <td
><input type
="button" name
="button2" value
="Alert 2" onmouseup
="javascript:doAlert2()"></td
>
120 <%-- If we actually had defined a tag library
. --%>
121 <table width
="400" cellpadding
="0" cellspacing
="0" border
="0">
123 <my
:SampleTag prop1
="first" prop2
="third">
124 <my
:SampleTagChild nameProp
="value1"/>
125 <my
:SampleTagChild nameProp
="value2"/>
131 <%-- Expression language
. --%>
132 <table width
="400" cellpadding
="0" cellspacing
="0" border
="0">
133 <c
:if test
="${!empty param.aParam}">
134 <c
:set var="myParam" scope
="session" value
="${param.aParam}"/>
137 <tr
><td
>myParam
's value: "<c:out value="${myParam}" default=="Default"/>"</td></tr>
142 /* A place for class variables and functions... */
144 // Define some sample parameter names that this page might understand.
145 private static final String PARAMETER_1 = "p1";
146 private static final String PARAMETER_2 = "p2";
147 private static final String PARAMETER_3 = "p3";
148 private static final String PARAMETER_4 = "p4";
149 private static final String PARAMETER_5 = "p5";
151 // Returns str trimmed, or an empty string if str is null.
152 private static String noNull(String str) {
162 // Returns a list of Integers with listSize elements.
163 private static List getIntList(int listSize) {
164 ArrayList retList = new ArrayList(listSize);
165 for (int i = 0; i < listSize; i++)
166 retList.add(new Integer( (int) (Math.random() * 100) ));