Advertisement
Guest User

JSP

a guest
Sep 23rd, 2018
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.69 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <%@ page language="java" contentType="text/html"%>
  3. <%@ page import="java.text.*,java.util.*" %>
  4.  
  5. <%--I commented this one because of I had compilation errors--%>
  6. <%--<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>--%>
  7. <%@page import="java.util.List"%>
  8. <%@page import="java.util.ArrayList"%>
  9.  
  10.  
  11.  
  12.  
  13. <html>
  14. <head>
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.     <meta name="viewport" content="width=device-width, initial-scale=1">
  23.     <style>
  24.         body {
  25.             font-family: "Lato", sans-serif;
  26.         }
  27.  
  28.         .sidenav {
  29.             height: 100%;
  30.             width: 160px;
  31.             position: fixed;
  32.             z-index: 1;
  33.             top: 0;
  34.             left: 0;
  35.             background-color: #111;
  36.             overflow-x: hidden;
  37.             padding-top: 20px;
  38.         }
  39.  
  40.         .topnav {
  41.             background-color: #333;
  42.             overflow: hidden;
  43.         }
  44.  
  45.         /* Style the links inside the navigation bar */
  46.         .topnav a {
  47.             float: left;
  48.             color: #f2f2f2;
  49.             text-align: center;
  50.             text-decoration: none;
  51.             font-size: 17px;
  52.             margin-left: 160px; /* Same as the width of the sidenav */
  53.             padding: 5px 10px;
  54.         }
  55.  
  56.         /* Change the color of links on hover */
  57.         .topnav a:hover {
  58.             background-color: #ddd;
  59.             color: black;
  60.         }
  61.  
  62.         /* Add a color to the active/current link */
  63.         .topnav a.active {
  64.             background-color: #4CAF50;
  65.             color: white;
  66.         }
  67.  
  68.  
  69.         .sidenav a {
  70.             padding: 6px 8px 6px 16px;
  71.             text-decoration: none;
  72.             font-size: 25px;
  73.             color: #818181;
  74.             display: block;
  75.         }
  76.  
  77.         .sidenav a:hover {
  78.             color: #f1f1f1;
  79.         }
  80.  
  81.         .main {
  82.             margin-left: 160px; /* Same as the width of the sidenav */
  83.             font-size: 28px; /* Increased text to enable scrolling */
  84.             padding: 0px 10px;
  85.         }
  86.  
  87.         @media screen and (max-height: 450px) {
  88.             .sidenav {padding-top: 15px;}
  89.             .sidenav a {font-size: 18px;}
  90.         }
  91.     </style>
  92. </head>
  93. <body>
  94.  
  95.  
  96. <div class="sidenav">
  97.     <a href="#about">About</a>
  98.     <a href="#services">Services</a>
  99.     <a href="#clients">Clients</a>
  100.     <a href="#contact">Contact</a>
  101.     <a href="#okk">${fileNames}</a>
  102.  
  103.  
  104.  
  105.  
  106. </div>
  107.  
  108. <div class="topnav">
  109.     <a class="active" href="#home">Home</a>
  110.     <a href="#news">News</a>
  111.     <a href="#contact">Contact</a>
  112.     <a href="#about">About</a>
  113. </div>
  114.  
  115. <div class = "main">
  116.  
  117.  
  118.  
  119.  
  120.  
  121. <%--I commented these 3 lines, because I had a compilation error--%>
  122.  
  123.     <%--<c:forEach var="files" items="${fileNames}" >--%>
  124.         <%--${files}--%>
  125.     <%--</c:forEach>--%>
  126.  
  127. </div>
  128.  
  129.  
  130. <%@ page import="java.io.*" %>
  131. <%@ page import="java.io.File" %>
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138. <table class="main" id="tableMain">
  139.     <thead>
  140.     <th scope="col">File Name</th>
  141.     <%
  142.  
  143.        List<String> itemsArray = (ArrayList<String>) request.getAttribute("names");
  144.  
  145.         if(itemsArray!=null) {
  146.             for (String name : itemsArray) {
  147.  
  148.                 out.println("<tr>");
  149.                 out.println("<td>" + name + "</td>");
  150.                 out.println("</tr>");
  151.             }
  152.         }
  153.  
  154.  
  155.     %></table>
  156.  
  157. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  158.  
  159. <script>
  160.     $('#tableMain').on('click', 'tr', function (e) {
  161.         //alert("Damn");
  162.         var tableData = $(this).children("td").map(function() {
  163.             return $(this).text();
  164.         }).get();
  165.         var td=tableData[0];
  166.         alert(td)
  167.     });
  168. </script>
  169.  
  170.  
  171.  
  172. </body>
  173.  
  174. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement