Simple.jsp
资源名称:某公司的java培训教材 [点击查看]
上传用户:dinglihq
上传日期:2013-02-04
资源大小:99958k
文件大小:2k
源码类别:
Java编程
开发平台:
Java
- <%-- Page Directives --%>
- <%@ page session="false" errorPage="Error.jsp" %>
- <%-- Declarations --%>
- <%! int end; %>
- <html>
- <head>
- <title>Simple JSP</title>
- <link href="jsp.css" type=text/css rel=stylesheet>
- <script language=JavaScript1.2>
- function openHelp(url) {
- var winname = "help"
- var winprops = "toolbar=0, location=0, status=1, menubar=0, scrollbars=1, resizable=1, width=450, height=300"
- var win = window.open(url , winname, winprops);
- win.window.focus();
- }
- </script>
- </head>
- <body>
- <%@ include file="Header.jsp" %>
- <table cellSpacing=0 cellPadding=0 border=0 width="100%">
- <tr>
- <td>
- <span class="sectionTitle">Simple JSP</span>
- </td>
- <td align=right><A href="Help.jsp?helpdoc=help_simple.htm" onclick="javascript:openHelp(this.href);return false;">Help</A>
- </td>
- </tr>
- </table>
- <%
- // get the request parameter for the input field
- String endParm = request.getParameter("end");
- if (endParm != null) end = Integer.parseInt(endParm);
- %>
- <form action="Simple.jsp" method="get" name="prompt" id="prompt">
- <span class="prompt">Last number: </span>
- <input type="text" name="end" size="10" maxlength="2" value="<%= end %>">
- <span class="prompt">(1 - 20)</span>
- </form>
- <% // only output table if valid value
- if (end > 0 && end <= 20) { %>
- <table>
- <tr>
- <td>Number</td>
- <td>Squared</td>
- <td>Cubed</td>
- </tr>
- <% // Share square and cube of 1 through 10
- for (int i = 1; i <= end; i++ ) { %>
- <tr>
- <td align=center><%= i %></td>
- <td align=center><%= i * i %></td>
- <td align=center><%= i * i * i %></td>
- </tr>
- <% } %>
- </table>
- <% // otherwise display error message
- } else if (endParm != null) { %>
- <span class="errorText">Only values between 1 and 20 are allowed.</span>
- <% } %>
- <%@ include file="Footer.htm" %>
- <script language=JavaScript1.2>
- // set focus
- document.prompt.end.focus();
- </script>
- </body>
- </html>