Advertisement
Guest User

Untitled

a guest
Dec 1st, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.15 KB | None | 0 0
  1. <%--
  2.     Document   : index
  3.     Created on : 2015-12-01, 12:40:43
  4.     Author     : kamil
  5. --%>
  6.  
  7. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  8. <!DOCTYPE html>
  9. <html>
  10.     <head>
  11.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  12.         <title>JSP Page</title>
  13. <style>
  14.  
  15. #customers td, #customers th {
  16.     font-size: 1em;
  17.     border: 1px solid #90bf20;
  18.     padding: 10px 10px 10px 47px;
  19. }
  20.  
  21. #customers th {
  22.     font-size: 1.1em;
  23.     text-align: left;
  24.     padding-top: 5px;
  25.     padding-bottom: 4px;
  26.     background-color: #222222;
  27.     color: #cccccc;
  28. }
  29.  
  30. #customers tr.alt td {
  31.     color: #999999;
  32.     background-color: #EAF2D3;
  33. }
  34. #customers td.alt2 {
  35.     color: #999999;
  36.     background-color: #FF8888;
  37. }
  38. </style>
  39. <%!public void formularz(javax.servlet.jsp.JspWriter out, int x, int y) throws java.io.IOException {
  40. //, boolean wyb
  41.    
  42.     int liczba_wierszy =x;
  43.     int liczba_kolumn=y;
  44.     int i =0;
  45.     int j =0;
  46.         boolean czy;
  47.        
  48.        
  49.        
  50.  
  51.        
  52.    
  53.     out.print("<table id='customers'>");
  54.     out.print("<tr><th></th>");
  55.  
  56.    
  57.     for (i = 1; i <= liczba_kolumn; i++) {
  58.           out.print("<th>"+i+"</th>");
  59.         }
  60.    
  61.     out.print("</tr>");
  62.  
  63.  
  64.  
  65. for (i = 1; i <= liczba_wierszy; i++) {
  66.     if (i % 2 == 0)
  67.          out.print("<tr class='alt'>") ;
  68. else
  69.     out.print("<tr>");
  70.     out.print ("<th>"+i+"</th>");
  71.        
  72.     for (j = 1; j <= liczba_kolumn; j++) {
  73.         if (i == j)
  74.     out.print("<td class='alt2'>") ; // po przekatnej
  75.         else
  76.         out.print ("<td>");
  77.        
  78.         //
  79. /*        if(wyb==false)
  80.         out.print( String.valueOf(j*i));
  81.         else {
  82.         czy= (Math.random() < 0.5);
  83.         if (czy==true){
  84.         out.print( String.valueOf(j*i));    
  85.         }
  86.         }*/
  87.        
  88.         out.print ("</td>");
  89.     }
  90.     out.print( "</tr>");  
  91.    
  92. }
  93.  
  94. out.print("</table>");
  95.  
  96. }%>
  97.  
  98. <%!public void formularz() {%>
  99.  
  100. <form action="index.jsp" method="post">
  101.     <table>
  102.         <tr>
  103.             <td>X:</td>
  104.             <td><input type=text name="x" /></td>
  105.         </tr>
  106.         <tr>
  107.             <td>Y:</td>
  108.             <td><input type="text" name="y" /></td>
  109.         </tr>
  110.         <tr>
  111.                    
  112.             <td colspan="2" align="center">
  113. <!--                            Puste pola:-->
  114. <!--                            <input type="checkbox" name="wybor" value="Puste pola" />-->
  115.                             <input type="submit"value="Rysuj" name="submit" />
  116. <!--                            <input type="reset" value="Wyczyść" />-->
  117.             </td>
  118.         </tr>
  119.     </table>
  120. </form>
  121.  
  122. <%!}%>
  123. </head>
  124. <body>
  125.  
  126.  
  127.  
  128.     <%
  129.         request.setCharacterEncoding("UTF-8");
  130.  
  131.         String x = request.getParameter("x");
  132.         String y = request.getParameter("y");
  133. //                boolean wyb = request.getParameter("wybor")!= null;
  134.  
  135.         if (x != null && y != null) {
  136.  
  137.             int a = Integer.valueOf(x);
  138.             int b = Integer.valueOf(y);
  139.                         //boolean c = Boolean.valueOf(wyb);
  140.            
  141.  
  142.             System.out.println(a);
  143.             System.out.println(b);
  144. //                        System.out.println(wyb);
  145.  
  146.  
  147. //          formularz(out, a, b, wyb);
  148.                         formularz(out, a, b);
  149.         }
  150.  
  151.         if (x == null || y == null) {
  152.             formularz();
  153.         }
  154.     %>
  155.  
  156.  
  157. </body>
  158.  
  159. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement