Mercurial > hg > digilib-old
changeset 60:58d23f512c80
New DigilibServlet.jar with new version (with DigilibRequest object).
Changes in digilib, digicat, dlImage JSP. Initialization now done only
once in jspInit. Uses DigilibRequest object to convert old +++-style
requests to parameter-style requests and for BaseURL.
Prettyfied config files (no authentication is default).
author | robcast |
---|---|
date | Wed, 28 Aug 2002 20:17:35 +0200 |
parents | 8d9a0abf3626 |
children | bacf7d60f185 |
files | client/digitallibrary/WEB-INF/digilib-auth.xml client/digitallibrary/WEB-INF/digilib-config.xml client/digitallibrary/WEB-INF/lib/DigilibServlet.jar client/digitallibrary/WEB-INF/web.xml client/digitallibrary/digicat.jsp client/digitallibrary/digilib.jsp client/digitallibrary/dlImage.jsp |
diffstat | 7 files changed, 107 insertions(+), 184 deletions(-) [+] |
line wrap: on
line diff
--- a/client/digitallibrary/WEB-INF/digilib-auth.xml Wed Aug 28 20:00:21 2002 +0200 +++ b/client/digitallibrary/WEB-INF/digilib-auth.xml Wed Aug 28 20:17:35 2002 +0200 @@ -1,5 +1,4 @@ -<!-- ---> +<!-- Authentication configuration file for Digital Document Library --> <auth-config> <digilib-paths>
--- a/client/digitallibrary/WEB-INF/digilib-config.xml Wed Aug 28 20:00:21 2002 +0200 +++ b/client/digitallibrary/WEB-INF/digilib-config.xml Wed Aug 28 20:17:35 2002 +0200 @@ -18,7 +18,7 @@ (see tomcat-users.xml). Authorization for resources (directories) is evaluated by the servlet (see auth-file). --> - <parameter name="use-authorization" value="true" /> + <parameter name="use-authorization" value="false" /> <!-- URL location of XML file with authorization requirements. --> <parameter name="auth-file" value="/docuserver/www/digitallibrary/WEB-INF/digilib-auth.xml" />
--- a/client/digitallibrary/WEB-INF/web.xml Wed Aug 28 20:00:21 2002 +0200 +++ b/client/digitallibrary/WEB-INF/web.xml Wed Aug 28 20:17:35 2002 +0200 @@ -3,15 +3,15 @@ "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> - <!-- General description of your web application --> - <display-name> + <!-- General description of your web application --> + <display-name> digilib - </display-name> - <description> + </display-name> + <description> This is the web frontend of the Digital Document Library. - </description> - <!-- The Scaler servlet --> - <servlet> + </description> + <!-- The Scaler servlet --> + <servlet> <servlet-name> Scaler </servlet-name> @@ -34,10 +34,9 @@ <load-on-startup> 5 </load-on-startup> - </servlet> - - <!-- We want to finger around with the default JSP servlet... --> - <servlet> + </servlet> + <!-- We want to finger around with the default JSP servlet... --> + <servlet> <servlet-name> doc-jsp </servlet-name> @@ -64,30 +63,27 @@ <load-on-startup> 3 </load-on-startup> - </servlet> - - <!-- The mapping for the Scaler servlet --> - <servlet-mapping> + </servlet> + <!-- The mapping for the Scaler servlet --> + <servlet-mapping> <servlet-name> Scaler </servlet-name> <url-pattern> /servlet/Scaler/* </url-pattern> - </servlet-mapping> - - <!-- The mapping for the JSP servlet --> - <servlet-mapping> + </servlet-mapping> + <!-- The mapping for the JSP servlet --> + <servlet-mapping> <servlet-name> doc-jsp </servlet-name> <url-pattern> *.jsp </url-pattern> - </servlet-mapping> - - <!-- region for authenticated access --> - <security-constraint> + </servlet-mapping> + <!-- region for authenticated access --> + <security-constraint> <web-resource-collection> <web-resource-name> Authenticated Digilib @@ -102,9 +98,9 @@ user </role-name> </auth-constraint> - </security-constraint> - <login-config> - <!-- + </security-constraint> + <login-config> + <!-- <auth-method>BASIC</auth-method> <realm-name>digilib</realm-name> --> @@ -119,5 +115,5 @@ /digilib-fail.html </form-error-page> </form-login-config> - </login-config> + </login-config> </web-app>
--- a/client/digitallibrary/digicat.jsp Wed Aug 28 20:00:21 2002 +0200 +++ b/client/digitallibrary/digicat.jsp Wed Aug 28 20:17:35 2002 +0200 @@ -1,40 +1,50 @@ +<%@ page language="java" %> + +<%! +// authentication stuff - robert +// ----------------------------- +// create DocumentBean instance for all JSP requests +digilib.servlet.DocumentBean docBean = new digilib.servlet.DocumentBean(); + +// initialize DocumentBean instance in JSP init +public void jspInit() { + try { + // set servlet init-parameter + docBean.setConfig(getServletConfig()); + } catch (javax.servlet.ServletException e) { + System.out.println(e); + } +} +%> + +<% +// check if authentication is needed and redirect if necessary +docBean.doAuthentication(request, response); + +// set up request object for base URL +digilib.servlet.DigilibRequest dlRequest = new digilib.servlet.DigilibRequest(); +dlRequest.setBaseURL(request); + +%> + <html> <head> -<jsp:useBean id="DB" scope="page" class="digilib.servlet.DocumentBean" /> - -<% -// set servlet init-parameter -DB.setConfig(getServletConfig()); -// check if authentication is needed and redirect if necessary -DB.doAuthentication(request, response); - -// calculate base URL string from request (minus last part) -String baseUrl = request.getRequestURL().toString(); -int eop = baseUrl.lastIndexOf("/"); -if (eop > 0) { - baseUrl = baseUrl.substring(0, eop); -} else { - baseUrl = "http://" + request.getServerName() + "/docuserver/digitallibrary"; -} - -%> - <script language="JavaScript"> -var baseUrl = "<%= baseUrl %>"; +var baseUrl = "<%= dlRequest.getBaseURL() %>"; // DEBUG -//alert('DIR: <%= DB.getDocuPath(request) %> PAGES: <%= DB.getNumPages(request) %>'); +//alert('DIR: <%= docBean.getDocuPath(request) %> PAGES: <%= docBean.getNumPages(request) %>'); // the document's query string (minus "?") var query = location.search.substring(1); // first page number -var firstPage = <%= DB.getFirstPage(request) %>; +var firstPage = <%= docBean.getFirstPage(request) %>; // number of pages of the document -var numPages = <%= DB.getNumPages(request) %>; +var numPages = <%= docBean.getNumPages(request) %>; // browser version test to include the corresponding navigation-file if ((navigator.appName.toLowerCase() == "netscape") && (parseFloat(navigator.appVersion) < 5.0)) {
--- a/client/digitallibrary/digilib.jsp Wed Aug 28 20:00:21 2002 +0200 +++ b/client/digitallibrary/digilib.jsp Wed Aug 28 20:17:35 2002 +0200 @@ -1,103 +1,43 @@ -<%@ page language="java" import="java.util.*" %> +<%@ page language="java" %> + +<%! +// authentication stuff - robert +// ----------------------------- +// create DocumentBean instance for all JSP requests +digilib.servlet.DocumentBean docBean = new digilib.servlet.DocumentBean(); + +// initialize DocumentBean instance in JSP init +public void jspInit() { + try { + // set servlet init-parameter + docBean.setConfig(getServletConfig()); + } catch (javax.servlet.ServletException e) { + System.out.println(e); + } +} +%> + +<% +// check if authentication is needed and redirect if necessary +docBean.doAuthentication(request, response); + +// parsing the query +// ----------------- + +digilib.servlet.DigilibRequest dlRequest = new digilib.servlet.DigilibRequest(); +// fill the request with the old format query string +dlRequest.setWithOldString(request.getQueryString()); +// add number of pages +dlRequest.setPt(docBean.getNumPages(request)); +// retrieve request in new paramter format +String query = "dlImage.jsp?" + dlRequest.getAsString(); +%> <html> <head> <title>Digital Document Library</title> </head> -<jsp:useBean id="DB" scope="page" class="digilib.servlet.DocumentBean" /> - -<% -// authentication stuff - robert -// ----------------------------- - -// set servlet init-parameter -DB.setConfig(getServletConfig()); -// check if authentication is needed and redirect if necessary -DB.doAuthentication(request, response); - - -// parsing the query -// ----------------- - -String query = "dlImage.jsp?"; -String token; - -if (request.getQueryString() != null) { - // have to enable the passing of delimiter to get empty parameters - StringTokenizer tokenizer = new StringTokenizer(request.getQueryString(), "+", true); - - // looks ugly but it works - hopefully... - - if (tokenizer.hasMoreTokens()) { - token = tokenizer.nextToken(); - if (token != "+") { - query += "fn=" + token; - if (tokenizer.hasMoreTokens()) tokenizer.nextToken(); - } - } - if (tokenizer.hasMoreTokens()) { - token = tokenizer.nextToken(); - if (token != "+") { - query += "&pn=" + token; - if (tokenizer.hasMoreTokens()) tokenizer.nextToken(); - } - } - if (tokenizer.hasMoreTokens()) { - token = tokenizer.nextToken(); - if (token != "+") { - query += "&ws=" + token; - if (tokenizer.hasMoreTokens()) tokenizer.nextToken(); - } - } - if (tokenizer.hasMoreTokens()) { - token = tokenizer.nextToken(); - if (!token.equals("+")) { - query += "&mo=" + token; - if (tokenizer.hasMoreTokens()) tokenizer.nextToken(); - } - } - if (tokenizer.hasMoreTokens()) { - token = tokenizer.nextToken(); - if (!token.equals("+")) { - query += "&mk=" + token; - if (tokenizer.hasMoreTokens()) tokenizer.nextToken(); - } - } - if (tokenizer.hasMoreTokens()) { - token = tokenizer.nextToken(); - if (token != "+") { - query += "&wx=" + token; - if (tokenizer.hasMoreTokens()) tokenizer.nextToken(); - } - } - if (tokenizer.hasMoreTokens()) { - token = tokenizer.nextToken(); - if (token != "+") { - query += "&wy=" + token; - if (tokenizer.hasMoreTokens()) tokenizer.nextToken(); - } - } - if (tokenizer.hasMoreTokens()) { - token = tokenizer.nextToken(); - if (token != "+") { - query += "&ww=" + token; - if (tokenizer.hasMoreTokens()) tokenizer.nextToken(); - } - } - if (tokenizer.hasMoreTokens()) { - token = tokenizer.nextToken(); - if (token != "+") { - query += "&wh=" + token; - if (tokenizer.hasMoreTokens()) tokenizer.nextToken(); - } - } - - // a module update for total number of pages - query += "&pt=" + DB.getNumPages(request); -} -%> - <frameset cols="*,90" border="0"> <frame name="mainFrame" src="<%= query %>" scrolling="auto"> <frameset rows="20,*" border="0">
--- a/client/digitallibrary/dlImage.jsp Wed Aug 28 20:00:21 2002 +0200 +++ b/client/digitallibrary/dlImage.jsp Wed Aug 28 20:17:35 2002 +0200 @@ -27,54 +27,32 @@ <% } else { +digilib.servlet.DigilibRequest dlRequest = new digilib.servlet.DigilibRequest(); // default values for parameters -String fn = "/"; // url of the page/document -String pn = "1"; // page number -String ws = "1"; // scale factor -String mo = ""; // special options like 'fit' for gifs -String mk = "0/0"; // marks -String wx = "0"; // left edge of image (float from 0 to 1) -String wy = "0"; // top edge in image (float from 0 to 1) -String ww = "1"; // width of image (float from 0 to 1) -String wh = "1"; // height of image (float from 0 to 1) -String dw = ""; // width of client in pixels -String dh = ""; // height of client in pixels - -String pt = ""; // (module pagesTotal.js) total number of pages - +dlRequest.setFn("/"); // url of the page/document +dlRequest.setPn(1); // page number +dlRequest.setWs(1); // scale factor +dlRequest.setMo(""); // special options like 'fit' for gifs +dlRequest.setMk("0/0"); // marks +dlRequest.setWx(0); // left edge of image (float from 0 to 1) +dlRequest.setWy(0); // top edge in image (float from 0 to 1) +dlRequest.setWw(1); // width of image (float from 0 to 1) +dlRequest.setWh(1); // height of image (float from 0 to 1) // overrriding default parameters with provided parameters from query-string -if (request.getParameter("fn") != null) fn = request.getParameter("fn"); -if (request.getParameter("pn") != null) pn = request.getParameter("pn"); -if (request.getParameter("ws") != null) ws = request.getParameter("ws"); -if (request.getParameter("mo") != null) mo = request.getParameter("mo"); -if (request.getParameter("mk") != null) mk = request.getParameter("mk"); -if (request.getParameter("wx") != null) wx = request.getParameter("wx"); -if (request.getParameter("wy") != null) wy = request.getParameter("wy"); -if (request.getParameter("ww") != null) ww = request.getParameter("ww"); -if (request.getParameter("wh") != null) wh = request.getParameter("wh"); -if (request.getParameter("dw") != null) dw = request.getParameter("dw"); -if (request.getParameter("dh") != null) dh = request.getParameter("dh"); -if (request.getParameter("pt") != null) pt = request.getParameter("pt"); +dlRequest.setWithRequest(request); //String imageLocation = "http://" + request.getServerName() + "/docuserver/digitallibrary/servlet/Scaler/" + fn + "?pn=" + pn + "&ws=" + ws + "&mo=" + mo + "&wx=" + wx + "&wy=" + wy + "&ww=" + ww + "&wh=" + wh + "&dw=" + dw + "&dh=" + dh; -String baseUrl = request.getRequestURL().toString(); -int eop = baseUrl.lastIndexOf("/"); -if (eop > 0) { - baseUrl = baseUrl.substring(0, eop); -} else { - baseUrl = "http://" + request.getServerName() + "/docuserver/digitallibrary"; -} +String baseUrl = dlRequest.getBaseURL(); -String imageLocation = baseUrl + "/servlet/Scaler/" + fn + "?pn=" + pn + "&ws=" + ws + "&mo=" + mo + "&wx=" + wx + "&wy=" + wy + "&ww=" + ww + "&wh=" + wh + "&dw=" + dw + "&dh=" + dh; - +String imageLocation = dlRequest.getBaseURL() + "/servlet/Scaler/?" + dlRequest.getAsString(); %> <html> <head> <script language="JavaScript"> -var baseUrl = "<%= baseUrl %>"; +var baseUrl = "<%= dlRequest.getBaseURL() %>"; // browser version test to include the corresponding navigation-file if (navigator.userAgent.toLowerCase().indexOf("opera") > -1) { @@ -96,7 +74,7 @@ </script> </head> -<body bgcolor="#666666" onload='init_pagesTotal("<%= fn %>", "<%= pn %>", "<%= ws %>", "<%= mo %>", "<%= mk %>", "<%= wx %>", "<%= wy %>", "<%= ww %>", "<%= wh %>", "<%= pt %>")'> +<body bgcolor="#666666" onload='init_pagesTotal("<%= dlRequest.getFn() %>", "<%= dlRequest.getPn() %>", "<%= dlRequest.getWs() %>", "<%= dlRequest.getMo() %>", "<%= dlRequest.getMk() %>", "<%= dlRequest.getWx() %>", "<%= dlRequest.getWy() %>", "<%= dlRequest.getWw() %>", "<%= dlRequest.getWh() %>", "<%= dlRequest.getPt() %>")'> <div id="lay1" style="position: absolute; left: 10px; top: 10px; visibility: visible"><img name="pic" src="<%= imageLocation %>" border="0"></div>