| 1 |
<%-- |
| 2 |
This page won't actually work, as it is simply designed to display jsp syntax highlighting. |
| 3 |
--%> |
| 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.*, |
| 7 |
java.io.*, |
| 8 |
java.math.*" %> |
| 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"/> |
| 12 |
<% |
| 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(); |
| 19 |
|
| 20 |
// A sample collection of Integers to display some code folding. |
| 21 |
List intList = getIntList(10); |
| 22 |
|
| 23 |
|
| 24 |
%> |
| 25 |
<html> |
| 26 |
<title>A Sample Jsp</title> |
| 27 |
<head> |
| 28 |
<script language="javascript"><!-- |
| 29 |
function doAlert1() { |
| 30 |
alert("This is the first javascript example."); |
| 31 |
} |
| 32 |
|
| 33 |
function doAlert2() { |
| 34 |
alert("This is the second javascript example."); |
| 35 |
} |
| 36 |
//--></script> |
| 37 |
<style type="text/css"> |
| 38 |
body{ color: yellow; } |
| 39 |
</style> |
| 40 |
</head> |
| 41 |
<body> |
| 42 |
<%-- The top label table. --%> |
| 43 |
<table width="400" cellpadding="0" cellspacing="0" border="0"> |
| 44 |
<tr> |
| 45 |
<td><font size="3"><b>The following parameters were detected:</b></font></td> |
| 46 |
</tr> |
| 47 |
</table> |
| 48 |
|
| 49 |
<%-- Display the parameters which might have been passed in. --%> |
| 50 |
<table width="400" cellpadding="0" cellspacing="0" border="0"> |
| 51 |
<%-- Label; Actual Parameter String; Value Detected --%> |
| 52 |
<tr> |
| 53 |
<td><b>PARAMETER_1</b></td> |
| 54 |
<td align="center"><%=PARAMETER_1%></td> |
| 55 |
<td align="right">"<%=parm1%>"</td> |
| 56 |
</tr> |
| 57 |
|
| 58 |
<%-- Label; Actual Parameter String; Value Detected --%> |
| 59 |
<tr> |
| 60 |
<td><b>PARAMETER_2</b></td> |
| 61 |
<td align="center"><%=PARAMETER_2%></td> |
| 62 |
<td align="right">"<%=parm2%>"</td> |
| 63 |
</tr> |
| 64 |
|
| 65 |
<%-- Label; Actual Parameter String; Value Detected --%> |
| 66 |
<tr> |
| 67 |
<td><b>PARAMETER_3</b></td> |
| 68 |
<td align="center"><%=PARAMETER_3%></td> |
| 69 |
<td align="right">"<%=parm3%>"</td> |
| 70 |
</tr> |
| 71 |
|
| 72 |
<%-- Label; Actual Parameter String; Value Detected --%> |
| 73 |
<tr> |
| 74 |
<td><b>PARAMETER_4</b></td> |
| 75 |
<td align="center"><%=PARAMETER_4%></td> |
| 76 |
<td align="right">"<%=parm4%>"</td> |
| 77 |
</tr> |
| 78 |
|
| 79 |
<%-- Label; Actual Parameter String; Value Detected --%> |
| 80 |
<tr> |
| 81 |
<td><b>PARAMETER_5</b></td> |
| 82 |
<td align="center"><%=PARAMETER_5%></td> |
| 83 |
<td align="right">"<%=parm5%>"</td> |
| 84 |
</tr> |
| 85 |
</table> |
| 86 |
|
| 87 |
<br><br> |
| 88 |
|
| 89 |
<%-- Display our list of random Integers (shows code folding). --%> |
| 90 |
<table width="400" cellpadding="0" cellspacing="0" border="0"> |
| 91 |
<% |
| 92 |
if (intList != null && intList.size() > 0) { |
| 93 |
%> |
| 94 |
<tr><td><b>Here are the elements of intList...</b></td></tr> |
| 95 |
<% |
| 96 |
Iterator intListIt = intList.iterator(); |
| 97 |
while (intListIt.hasNext()) { |
| 98 |
Integer i = (Integer) intListIt.next(); |
| 99 |
%> |
| 100 |
<tr><td><%=i.toString()%></td></tr> |
| 101 |
<% |
| 102 |
} |
| 103 |
} else { |
| 104 |
%> |
| 105 |
<tr><td><font color="blue"><b><i>Oooops, we forgot to initialize intList!</i></b></font></td></tr> |
| 106 |
<% |
| 107 |
} |
| 108 |
%> |
| 109 |
</table> |
| 110 |
|
| 111 |
<br><br> |
| 112 |
|
| 113 |
<%-- We can call javascript functions. --%> |
| 114 |
<table width="400" cellpadding="0" cellspacing="0" border="0"> |
| 115 |
<tr><td colspan="2"><b>Test our javascript...</b></td></tr> |
| 116 |
<tr> |
| 117 |
<td><input type="button" name="button1" value="Alert 1" onmouseup="javascript:doAlert1()"></td> |
| 118 |
<td><input type="button" name="button2" value="Alert 2" onmouseup="javascript:doAlert2()"></td> |
| 119 |
</tr> |
| 120 |
</table> |
| 121 |
|
| 122 |
<br><br> |
| 123 |
<%-- If we actually had defined a tag library. --%> |
| 124 |
<table width="400" cellpadding="0" cellspacing="0" border="0"> |
| 125 |
<tr><td> |
| 126 |
<my:SampleTag prop1="first" prop2="third"> |
| 127 |
<my:SampleTagChild nameProp="value1"/> |
| 128 |
<my:SampleTagChild nameProp="value2"/> |
| 129 |
</my:SampleTag> |
| 130 |
</td></tr> |
| 131 |
</table> |
| 132 |
|
| 133 |
<br><br> |
| 134 |
<%-- Expression language. --%> |
| 135 |
<table width="400" cellpadding="0" cellspacing="0" border="0"> |
| 136 |
<c:if test="${!empty param.aParam}"> |
| 137 |
<c:set var="myParam" scope="session" value="${param.aParam}"/> |
| 138 |
</c:if> |
| 139 |
|
| 140 |
<tr><td>myParam's value: "<c:out value="${myParam}" default=="Default"/>"</td></tr> |
| 141 |
</table> |
| 142 |
</body> |
| 143 |
</html> |
| 144 |
<%! |
| 145 |
/* A place for class variables and functions... */ |
| 146 |
|
| 147 |
// Define some sample parameter names that this page might understand. |
| 148 |
private static final String PARAMETER_1 = "p1"; |
| 149 |
private static final String PARAMETER_2 = "p2"; |
| 150 |
private static final String PARAMETER_3 = "p3"; |
| 151 |
private static final String PARAMETER_4 = "p4"; |
| 152 |
private static final String PARAMETER_5 = "p5"; |
| 153 |
|
| 154 |
// Returns str trimmed, or an empty string if str is null. |
| 155 |
private static String noNull(String str) { |
| 156 |
String retStr; |
| 157 |
if (str == null) |
| 158 |
retStr = ""; |
| 159 |
else |
| 160 |
retStr = str.trim(); |
| 161 |
|
| 162 |
return retStr; |
| 163 |
} |
| 164 |
|
| 165 |
// Returns a list of Integers with listSize elements. |
| 166 |
private static List getIntList(int listSize) { |
| 167 |
ArrayList retList = new ArrayList(listSize); |
| 168 |
for (int i = 0; i < listSize; i++) |
| 169 |
retList.add(new Integer( (int) (Math.random() * 100) )); |
| 170 |
|
| 171 |
return retList; |
| 172 |
} |
| 173 |
%> |