comparison client/digitallibrary/ImgInfo-json.jsp @ 753:39bd5128811c jquery

first real JSON jsp: ImgInfo-json.jsp
author robcast
date Sat, 05 Feb 2011 22:50:15 +0100
parents
children ce5a0e6b5ee9
comparison
equal deleted inserted replaced
752:fce27a005445 753:39bd5128811c
1 <%@page language="java"
2 import="digilib.io.FileOps, digilib.io.ImageFileset, digilib.io.ImageFile,
3 digilib.image.ImageSize, digilib.servlet.DigilibConfiguration"
4 contentType="application/json"%><%!
5 // create DocumentBean instance for all JSP requests
6 digilib.servlet.DocumentBean docBean = new digilib.servlet.DocumentBean();
7
8 // initialize DocumentBean instance in JSP init
9 public void jspInit() {
10 try {
11 // set servlet init-parameter
12 docBean.setConfig(getServletConfig());
13 } catch (javax.servlet.ServletException e) {
14 System.out.println(e);
15 }
16 }
17 %><%
18 // parsing the query
19 digilib.servlet.DigilibRequest dlRequest = new digilib.servlet.DigilibRequest(request);
20 docBean.setRequest(dlRequest);
21 // dir cache
22 digilib.servlet.DigilibConfiguration dlConfig = docBean.getDlConfig();
23 digilib.io.DocuDirCache dirCache = (digilib.io.DocuDirCache) dlConfig.getValue("servlet.dir.cache");
24 // get file
25 FileOps.FileClass fc = FileOps.FileClass.IMAGE;
26 ImageFileset imgFile = (ImageFileset) dirCache.getFile(dlRequest.getFilePath(), dlRequest.getAsInt("pn"), fc);
27
28 %>// JSON format metadata about an image
29 { <%
30 if (imgFile != null) {
31 ImageFile img = imgFile.getBiggest();
32 if (!img.isChecked()) {
33 DigilibConfiguration.docuImageIdentify(img);
34 }
35 ImageSize imgSize = img.getSize();
36 %>
37 "filename" : "<%= imgFile.getName() %>",
38 "aspect" : <%= imgFile.getAspect() %>,
39 "dpi_x" : <%= imgFile.getResX() %>,
40 "dpi_y" : <%= imgFile.getResY() %><%
41
42 if (imgSize != null) {
43 %>,
44 "width" : <%= imgSize.getWidth() %>,
45 "height" : <%= imgSize.getHeight() %>
46 <% }
47 }
48 %>}