Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%--
- Document : index
- Created on : 2015-12-01, 12:40:43
- Author : kamil
- --%>
- <%@page contentType="text/html" pageEncoding="UTF-8"%>
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>JSP Page</title>
- <style>
- #customers td, #customers th {
- font-size: 1em;
- border: 1px solid #90bf20;
- padding: 10px 10px 10px 47px;
- }
- #customers th {
- font-size: 1.1em;
- text-align: left;
- padding-top: 5px;
- padding-bottom: 4px;
- background-color: #222222;
- color: #cccccc;
- }
- #customers tr.alt td {
- color: #999999;
- background-color: #EAF2D3;
- }
- #customers td.alt2 {
- color: #999999;
- background-color: #FF8888;
- }
- </style>
- <%!public void formularz(javax.servlet.jsp.JspWriter out, int x, int y) throws java.io.IOException {
- //, boolean wyb
- int liczba_wierszy =x;
- int liczba_kolumn=y;
- int i =0;
- int j =0;
- boolean czy;
- out.print("<table id='customers'>");
- out.print("<tr><th></th>");
- for (i = 1; i <= liczba_kolumn; i++) {
- out.print("<th>"+i+"</th>");
- }
- out.print("</tr>");
- for (i = 1; i <= liczba_wierszy; i++) {
- if (i % 2 == 0)
- out.print("<tr class='alt'>") ;
- else
- out.print("<tr>");
- out.print ("<th>"+i+"</th>");
- for (j = 1; j <= liczba_kolumn; j++) {
- if (i == j)
- out.print("<td class='alt2'>") ; // po przekatnej
- else
- out.print ("<td>");
- //
- /* if(wyb==false)
- out.print( String.valueOf(j*i));
- else {
- czy= (Math.random() < 0.5);
- if (czy==true){
- out.print( String.valueOf(j*i));
- }
- }*/
- out.print ("</td>");
- }
- out.print( "</tr>");
- }
- out.print("</table>");
- }%>
- <%!public void formularz() {%>
- <form action="index.jsp" method="post">
- <table>
- <tr>
- <td>X:</td>
- <td><input type=text name="x" /></td>
- </tr>
- <tr>
- <td>Y:</td>
- <td><input type="text" name="y" /></td>
- </tr>
- <tr>
- <td colspan="2" align="center">
- <!-- Puste pola:-->
- <!-- <input type="checkbox" name="wybor" value="Puste pola" />-->
- <input type="submit"value="Rysuj" name="submit" />
- <!-- <input type="reset" value="Wyczyść" />-->
- </td>
- </tr>
- </table>
- </form>
- <%!}%>
- </head>
- <body>
- <%
- request.setCharacterEncoding("UTF-8");
- String x = request.getParameter("x");
- String y = request.getParameter("y");
- // boolean wyb = request.getParameter("wybor")!= null;
- if (x != null && y != null) {
- int a = Integer.valueOf(x);
- int b = Integer.valueOf(y);
- //boolean c = Boolean.valueOf(wyb);
- System.out.println(a);
- System.out.println(b);
- // System.out.println(wyb);
- // formularz(out, a, b, wyb);
- formularz(out, a, b);
- }
- if (x == null || y == null) {
- formularz();
- }
- %>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement