source: other-projects/nz-flag-design/trunk/main-form/published-names.jsp@ 29968

Last change on this file since 29968 was 29928, checked in by davidb, 9 years ago

JSP file for presenting in JSON format the names of the published folders

File size: 853 bytes
Line 
1<%@ page contentType="text/html; charset=UTF-8" %>
2<%@ page import="java.io.*,java.util.*,org.json.*" %>
3<%!
4 ArrayList<File> listDirsForFolder(final File folder) {
5 ArrayList<File> fileList = new ArrayList<File>();
6
7 for (final File fileEntry : folder.listFiles()) {
8 if (fileEntry.isDirectory()) {
9 if (!fileEntry.getName().startsWith(".")) {
10 fileList.add(fileEntry);
11 }
12 }
13 }
14
15 return fileList;
16 }
17%>
18<%
19 String doc_base = getServletContext().getRealPath("/");
20 File pub_dir = new File(doc_base,"published");
21
22 ArrayList<File> my_pub_dirs = listDirsForFolder(pub_dir);
23 JSONArray json = new JSONArray();
24
25 for (final File fileEntry : my_pub_dirs) {
26 json.put(fileEntry.getName());
27 }
28 out.println(json.toString());
29 out.flush();
30%>
Note: See TracBrowser for help on using the repository browser.