taiage-jsp/webapp/bloque.jsp

37 lines
1.1 KiB
Plaintext

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="java.io.File,java.util.ArrayList" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
String bloqueParam = request.getParameter("bloque");
String bloque = (bloqueParam != null) ? bloqueParam : "1";
String basePath = application.getRealPath("/../apuntes/bloque" + bloque);
File bloqueDir = new File(basePath);
ArrayList<String> temas = new ArrayList<>();
if (bloqueDir.exists() && bloqueDir.isDirectory()) {
for (File f : bloqueDir.listFiles()) {
if (f.getName().matches("tema[0-9]+.*\\.md")) {
temas.add(f.getName());
}
}
temas.sort(null);
}
%>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Bloque <%= bloque %> | TAI-AGE</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<h1>Bloque <%= bloque %></h1>
<h2>Temas disponibles</h2>
<ul>
<% for (String tema : temas) { %>
<li><a href="tema.jsp?bloque=<%= bloque %>&tema=<%= tema %>"><%= tema %></a></li>
<% } %>
</ul>
<a href="index.jsp">Volver al inicio</a>
</body>
</html>