changeset 1157:7a4f27ee087f

fix bug when calling Scaler without fn-parameter.
author robcast
date Tue, 19 Feb 2013 17:27:53 +0100
parents 4f84a635a820
children 2ee261676828
files servlet2/src/main/java/digilib/servlet/DigilibServletRequest.java servlet3/src/main/java/digilib/servlet/DigilibServletRequest.java
diffstat 2 files changed, 432 insertions(+), 436 deletions(-) [+]
line wrap: on
line diff
--- a/servlet2/src/main/java/digilib/servlet/DigilibServletRequest.java	Tue Feb 19 17:25:57 2013 +0100
+++ b/servlet2/src/main/java/digilib/servlet/DigilibServletRequest.java	Tue Feb 19 17:27:53 2013 +0100
@@ -160,10 +160,6 @@
 		newParameter("img.pix_y", new Integer(0), null, 'c');
 		// total number of pages
 		newParameter("pt", new Integer(0), null, 'c');
-		// display level of digilib (0 = just image, 1 = one HTML page
-		// 2 = in frameset, 3 = XUL-'frameset'
-		// 4 = XUL-Sidebar )
-		newParameter("lv", new Integer(2), null, 'c');
 		// marks
 		newParameter("mk", "", null, 'c');
 	}
@@ -193,7 +189,8 @@
 			} else if (qs.indexOf(";") > -1) {
 				// ; separator
 				setWithParamString(qs, ";");
-			} else if (request.getParameter("fn") != null) {
+			} else if (request.getParameter("fn") != null || 
+			        request.getParameter("dw") != null || request.getParameter("dh") != null) {
 				// standard '&' parameters
 				setWithParamRequest(request);
 			} else {
--- a/servlet3/src/main/java/digilib/servlet/DigilibServletRequest.java	Tue Feb 19 17:25:57 2013 +0100
+++ b/servlet3/src/main/java/digilib/servlet/DigilibServletRequest.java	Tue Feb 19 17:27:53 2013 +0100
@@ -63,9 +63,9 @@
  */
 public class DigilibServletRequest extends DigilibRequest {
 
-	protected DocuImage image; // internal DocuImage instance for this request
+    protected DocuImage image; // internal DocuImage instance for this request
 
-	protected HttpServletRequest servletRequest; // internal ServletRequest
+    protected HttpServletRequest servletRequest; // internal ServletRequest
 
     /**
      * Creates a new instance of DigilibRequest with parameters from a
@@ -78,97 +78,96 @@
         initOptions();
     }
 
-	/** set up parameters.
-	 * 
-	 */
-	protected void initParams() {
-		/*
-		 * Definition of parameters and default values. Parameter of type 's'
-		 * are for the servlet.
-		 */
+    /**
+     * set up parameters.
+     * 
+     */
+    protected void initParams() {
+        /*
+         * Definition of parameters and default values. Parameter of type 's'
+         * are for the servlet.
+         */
 
-		// url of the page/document (second part)
-		newParameter("fn", "", null, 's');
-		// page number
-		newParameter("pn", new Integer(1), null, 's');
-		// width of client in pixels
-		newParameter("dw", new Integer(0), null, 's');
-		// height of client in pixels
-		newParameter("dh", new Integer(0), null, 's');
-		// left edge of image (float from 0 to 1)
-		newParameter("wx", new Float(0), null, 's');
-		// top edge in image (float from 0 to 1)
-		newParameter("wy", new Float(0), null, 's');
-		// width of image (float from 0 to 1)
-		newParameter("ww", new Float(1), null, 's');
-		// height of image (float from 0 to 1)
-		newParameter("wh", new Float(1), null, 's');
-		// scale factor
-		newParameter("ws", new Float(1), null, 's');
-		// special options like 'fit' for gifs
-		newParameter("mo", this.options, null, 's');
-		// rotation angle (degree)
-		newParameter("rot", new Float(0), null, 's');
-		// contrast enhancement factor
-		newParameter("cont", new Float(0), null, 's');
-		// brightness enhancement factor
-		newParameter("brgt", new Float(0), null, 's');
-		// color multiplicative factors
-		newParameter("rgbm", "0/0/0", null, 's');
-		// color additive factors
-		newParameter("rgba", "0/0/0", null, 's');
-		// display dpi resolution (total)
-		newParameter("ddpi", new Float(0), null, 's');
-		// display dpi X resolution
-		newParameter("ddpix", new Float(0), null, 's');
-		// display dpi Y resolution
-		newParameter("ddpiy", new Float(0), null, 's');
-		// scale factor for mo=ascale
-		newParameter("scale", new Float(1), null, 's');
-		// color conversion operation
-		newParameter("colop", "", null, 's');
+        // url of the page/document (second part)
+        newParameter("fn", "", null, 's');
+        // page number
+        newParameter("pn", new Integer(1), null, 's');
+        // width of client in pixels
+        newParameter("dw", new Integer(0), null, 's');
+        // height of client in pixels
+        newParameter("dh", new Integer(0), null, 's');
+        // left edge of image (float from 0 to 1)
+        newParameter("wx", new Float(0), null, 's');
+        // top edge in image (float from 0 to 1)
+        newParameter("wy", new Float(0), null, 's');
+        // width of image (float from 0 to 1)
+        newParameter("ww", new Float(1), null, 's');
+        // height of image (float from 0 to 1)
+        newParameter("wh", new Float(1), null, 's');
+        // scale factor
+        newParameter("ws", new Float(1), null, 's');
+        // special options like 'fit' for gifs
+        newParameter("mo", this.options, null, 's');
+        // rotation angle (degree)
+        newParameter("rot", new Float(0), null, 's');
+        // contrast enhancement factor
+        newParameter("cont", new Float(0), null, 's');
+        // brightness enhancement factor
+        newParameter("brgt", new Float(0), null, 's');
+        // color multiplicative factors
+        newParameter("rgbm", "0/0/0", null, 's');
+        // color additive factors
+        newParameter("rgba", "0/0/0", null, 's');
+        // display dpi resolution (total)
+        newParameter("ddpi", new Float(0), null, 's');
+        // display dpi X resolution
+        newParameter("ddpix", new Float(0), null, 's');
+        // display dpi Y resolution
+        newParameter("ddpiy", new Float(0), null, 's');
+        // scale factor for mo=ascale
+        newParameter("scale", new Float(1), null, 's');
+        // color conversion operation
+        newParameter("colop", "", null, 's');
 
-		/*
-		 * Parameters of type 'i' are not exchanged between client and server,
-		 * but are for the servlets or JSPs internal use.
-		 */
+        /*
+         * Parameters of type 'i' are not exchanged between client and server,
+         * but are for the servlets or JSPs internal use.
+         */
 
-		// url of the page/document (first part, may be empty)
-		newParameter("request.path", "", null, 'i');
-		// base URL (from http:// to below /servlet)
-		newParameter("base.url", null, null, 'i');
-		// DocuImage instance for this request
-		newParameter("docu.image", image, null, 'i');
-		image = null;
-		// HttpServletRequest for this request
-		newParameter("servlet.request", servletRequest, null, 'i');
-		servletRequest = null;
+        // url of the page/document (first part, may be empty)
+        newParameter("request.path", "", null, 'i');
+        // base URL (from http:// to below /servlet)
+        newParameter("base.url", null, null, 'i');
+        // DocuImage instance for this request
+        newParameter("docu.image", image, null, 'i');
+        image = null;
+        // HttpServletRequest for this request
+        newParameter("servlet.request", servletRequest, null, 'i');
+        servletRequest = null;
 
-		/*
-		 * Parameters of type 'c' are for the clients use
-		 */
+        /*
+         * Parameters of type 'c' are for the clients use
+         */
 
-		// "real" filename
-		newParameter("img.fn", "", null, 'c');
-		// image dpi x
-		newParameter("img.dpix", new Integer(0), null, 'c');
-		// image dpi y
-		newParameter("img.dpiy", new Integer(0), null, 'c');
-		// hires image size x
-		newParameter("img.pix_x", new Integer(0), null, 'c');
-		// hires image size y
-		newParameter("img.pix_y", new Integer(0), null, 'c');
-		// total number of pages
-		newParameter("pt", new Integer(0), null, 'c');
-		// display level of digilib (0 = just image, 1 = one HTML page
-		// 2 = in frameset, 3 = XUL-'frameset'
-		// 4 = XUL-Sidebar )
-		newParameter("lv", new Integer(2), null, 'c');
-		// marks
-		newParameter("mk", "", null, 'c');
-	}
+        // "real" filename
+        newParameter("img.fn", "", null, 'c');
+        // image dpi x
+        newParameter("img.dpix", new Integer(0), null, 'c');
+        // image dpi y
+        newParameter("img.dpiy", new Integer(0), null, 'c');
+        // hires image size x
+        newParameter("img.pix_x", new Integer(0), null, 'c');
+        // hires image size y
+        newParameter("img.pix_y", new Integer(0), null, 'c');
+        // total number of pages
+        newParameter("pt", new Integer(0), null, 'c');
+        // marks
+        newParameter("mk", "", null, 'c');
+    }
 
-    /* (non-Javadoc)
+    /*
+     * (non-Javadoc)
+     * 
      * @see digilib.servlet.ParameterMap#initOptions()
      */
     @Override
@@ -176,363 +175,363 @@
         options = (OptionsSet) getValue("mo");
     }
 
-	/**
-	 * Populate the request object with data from a ServletRequest.
-	 * 
-	 * 
-	 * @param request
-	 */
-	public void setWithRequest(HttpServletRequest request) {
-		servletRequest = request;
-		// decide if it's old-style or new-style
-		String qs = ((HttpServletRequest) request).getQueryString();
-		if (qs != null) {
-			if (qs.indexOf("&") > -1) {
-				// & separator
-				setWithParamString(qs, "&");
-			} else if (qs.indexOf(";") > -1) {
-				// ; separator
-				setWithParamString(qs, ";");
-			} else if (request.getParameter("fn") != null) {
-				// standard '&' parameters
-				setWithParamRequest(request);
-			} else {
-				setWithOldString(qs);
-			}
-		}
-		setValue("servlet.request", request);
-		// add path from request
-		setValue("request.path", ((HttpServletRequest) request).getPathInfo());
-		// set the baseURL
-		setBaseURL((HttpServletRequest) request);
-	}
+    /**
+     * Populate the request object with data from a ServletRequest.
+     * 
+     * 
+     * @param request
+     */
+    public void setWithRequest(HttpServletRequest request) {
+        servletRequest = request;
+        // decide if it's old-style or new-style
+        String qs = ((HttpServletRequest) request).getQueryString();
+        if (qs != null) {
+            if (qs.indexOf("&") > -1) {
+                // & separator
+                setWithParamString(qs, "&");
+            } else if (qs.indexOf(";") > -1) {
+                // ; separator
+                setWithParamString(qs, ";");
+            } else if (request.getParameter("fn") != null || request.getParameter("dw") != null
+                    || request.getParameter("dh") != null) {
+                // standard '&' parameters
+                setWithParamRequest(request);
+            } else {
+                setWithOldString(qs);
+            }
+        }
+        setValue("servlet.request", request);
+        // add path from request
+        setValue("request.path", ((HttpServletRequest) request).getPathInfo());
+        // set the baseURL
+        setBaseURL((HttpServletRequest) request);
+    }
 
-	/**
-	 * Populate a request from a string in the old "++++" parameter form.
-	 * 
-	 * @param queryString
-	 *            String with paramters in the old "+++" form.
-	 */
-	public void setWithOldString(String queryString) {
-		if (queryString == null) {
-			return;
-		}
-		// enable the passing of delimiter to get empty parameters
-		StringTokenizer query = new StringTokenizer(queryString, "+", true);
-		String token;
-		// first parameter FN
-		if (query.hasMoreTokens()) {
-			token = query.nextToken();
-			if (!token.equals("+")) {
-				setValueFromString("fn", token);
-				if (query.hasMoreTokens()) {
-					query.nextToken();
-				}
-			}
-		}
-		// second parameter PN
-		if (query.hasMoreTokens()) {
-			token = query.nextToken();
-			if (!token.equals("+")) {
-				setValueFromString("pn", token);
-				if (query.hasMoreTokens()) {
-					query.nextToken();
-				}
-			}
-		}
-		// third parameter WS
-		if (query.hasMoreTokens()) {
-			token = query.nextToken();
-			if (!token.equals("+")) {
-				setValueFromString("ws", token);
-				if (query.hasMoreTokens()) {
-					query.nextToken();
-				}
-			}
-		}
-		// fourth parameter MO
-		if (query.hasMoreTokens()) {
-			token = query.nextToken();
-			if (!token.equals("+")) {
-				setValueFromString("mo", token);
-				if (query.hasMoreTokens()) {
-					query.nextToken();
-				}
-			}
-		}
-		// fifth parameter MK
-		if (query.hasMoreTokens()) {
-			token = query.nextToken();
-			if (!token.equals("+")) {
-				setValueFromString("mk", token);
-				if (query.hasMoreTokens()) {
-					query.nextToken();
-				}
-			}
-		}
-		// sixth parameter WX
-		if (query.hasMoreTokens()) {
-			token = query.nextToken();
-			if (!token.equals("+")) {
-				setValueFromString("wx", token);
-				if (query.hasMoreTokens()) {
-					query.nextToken();
-				}
-			}
-		}
-		// seventh parameter WY
-		if (query.hasMoreTokens()) {
-			token = query.nextToken();
-			if (!token.equals("+")) {
-				setValueFromString("wy", token);
-				if (query.hasMoreTokens()) {
-					query.nextToken();
-				}
-			}
-		}
-		// eigth parameter WW
-		if (query.hasMoreTokens()) {
-			token = query.nextToken();
-			if (!token.equals("+")) {
-				setValueFromString("ww", token);
-				if (query.hasMoreTokens()) {
-					query.nextToken();
-				}
-			}
-		}
-		// ninth parameter WH
-		if (query.hasMoreTokens()) {
-			token = query.nextToken();
-			if (!token.equals("+")) {
-				setValueFromString("wh", token);
-				if (query.hasMoreTokens()) {
-					query.nextToken();
-				}
-			}
-		}
-	}
+    /**
+     * Populate a request from a string in the old "++++" parameter form.
+     * 
+     * @param queryString
+     *            String with paramters in the old "+++" form.
+     */
+    public void setWithOldString(String queryString) {
+        if (queryString == null) {
+            return;
+        }
+        // enable the passing of delimiter to get empty parameters
+        StringTokenizer query = new StringTokenizer(queryString, "+", true);
+        String token;
+        // first parameter FN
+        if (query.hasMoreTokens()) {
+            token = query.nextToken();
+            if (!token.equals("+")) {
+                setValueFromString("fn", token);
+                if (query.hasMoreTokens()) {
+                    query.nextToken();
+                }
+            }
+        }
+        // second parameter PN
+        if (query.hasMoreTokens()) {
+            token = query.nextToken();
+            if (!token.equals("+")) {
+                setValueFromString("pn", token);
+                if (query.hasMoreTokens()) {
+                    query.nextToken();
+                }
+            }
+        }
+        // third parameter WS
+        if (query.hasMoreTokens()) {
+            token = query.nextToken();
+            if (!token.equals("+")) {
+                setValueFromString("ws", token);
+                if (query.hasMoreTokens()) {
+                    query.nextToken();
+                }
+            }
+        }
+        // fourth parameter MO
+        if (query.hasMoreTokens()) {
+            token = query.nextToken();
+            if (!token.equals("+")) {
+                setValueFromString("mo", token);
+                if (query.hasMoreTokens()) {
+                    query.nextToken();
+                }
+            }
+        }
+        // fifth parameter MK
+        if (query.hasMoreTokens()) {
+            token = query.nextToken();
+            if (!token.equals("+")) {
+                setValueFromString("mk", token);
+                if (query.hasMoreTokens()) {
+                    query.nextToken();
+                }
+            }
+        }
+        // sixth parameter WX
+        if (query.hasMoreTokens()) {
+            token = query.nextToken();
+            if (!token.equals("+")) {
+                setValueFromString("wx", token);
+                if (query.hasMoreTokens()) {
+                    query.nextToken();
+                }
+            }
+        }
+        // seventh parameter WY
+        if (query.hasMoreTokens()) {
+            token = query.nextToken();
+            if (!token.equals("+")) {
+                setValueFromString("wy", token);
+                if (query.hasMoreTokens()) {
+                    query.nextToken();
+                }
+            }
+        }
+        // eigth parameter WW
+        if (query.hasMoreTokens()) {
+            token = query.nextToken();
+            if (!token.equals("+")) {
+                setValueFromString("ww", token);
+                if (query.hasMoreTokens()) {
+                    query.nextToken();
+                }
+            }
+        }
+        // ninth parameter WH
+        if (query.hasMoreTokens()) {
+            token = query.nextToken();
+            if (!token.equals("+")) {
+                setValueFromString("wh", token);
+                if (query.hasMoreTokens()) {
+                    query.nextToken();
+                }
+            }
+        }
+    }
 
-	/**
-	 * Return the request parameters as a String in the parameter form
-	 * 'fn=/icons&pn=1'. Empty (undefined) fields are not included.
-	 * 
-	 * @return String of request parameters in parameter form.
-	 */
-	public String getAsString() {
-		return getAsString(0);
-	}
+    /**
+     * Return the request parameters as a String in the parameter form
+     * 'fn=/icons&pn=1'. Empty (undefined) fields are not included.
+     * 
+     * @return String of request parameters in parameter form.
+     */
+    public String getAsString() {
+        return getAsString(0);
+    }
 
-	/**
-	 * Return the request parameters of a given type type as a String in the
-	 * parameter form 'fn=/icons&pn=1'. Empty (undefined) fields are not
-	 * included.
-	 * 
-	 * @return String of request parameters in parameter form.
-	 */
-	public String getAsString(int type) {
-		StringBuffer s = new StringBuffer(50);
-		// go through all values
-		for (Parameter p: params.values()) {
-			if ((type > 0) && (p.getType() != type)) {
-				// skip the wrong types
-				continue;
-			}
-			String name = p.getName();
-			/*
-			 * handling special cases
-			 */
-			// request_path adds to fn
-			if (name.equals("fn")) {
-				s.append("&fn=" + getAsString("request.path")
-						+ getAsString("fn"));
-				continue;
-			}
-			/*
-			 * the rest is sent with its name
-			 */
-			// parameters that are not set or internal are not sent
-			if ((!p.hasValue()) || (p.getType() == 'i')) {
-				continue;
-			}
-			s.append("&" + name + "=" + p.getAsString());
-		}
-		// kill first "&"
-		s.deleteCharAt(0);
-		return s.toString();
-	}
+    /**
+     * Return the request parameters of a given type type as a String in the
+     * parameter form 'fn=/icons&pn=1'. Empty (undefined) fields are not
+     * included.
+     * 
+     * @return String of request parameters in parameter form.
+     */
+    public String getAsString(int type) {
+        StringBuffer s = new StringBuffer(50);
+        // go through all values
+        for (Parameter p : params.values()) {
+            if ((type > 0) && (p.getType() != type)) {
+                // skip the wrong types
+                continue;
+            }
+            String name = p.getName();
+            /*
+             * handling special cases
+             */
+            // request_path adds to fn
+            if (name.equals("fn")) {
+                s.append("&fn=" + getAsString("request.path") + getAsString("fn"));
+                continue;
+            }
+            /*
+             * the rest is sent with its name
+             */
+            // parameters that are not set or internal are not sent
+            if ((!p.hasValue()) || (p.getType() == 'i')) {
+                continue;
+            }
+            s.append("&" + name + "=" + p.getAsString());
+        }
+        // kill first "&"
+        s.deleteCharAt(0);
+        return s.toString();
+    }
 
-	/**
-	 * Returns request parameters in old '++++' form.
-	 * 
-	 * @return String with parameters in old '++++' form.
-	 */
-	public String getAsOldString() {
-		StringBuffer s = new StringBuffer(50);
-		s.append(getAsString("request.path"));
-		s.append(getAsString("fn"));
-		s.append("+" + getAsString("pn"));
-		s.append("+" + getAsString("ws"));
-		s.append("+" + getAsString("mo"));
-		s.append("+" + getAsString("mk"));
-		s.append("+" + getAsString("wx"));
-		s.append("+" + getAsString("wy"));
-		s.append("+" + getAsString("ww"));
-		s.append("+" + getAsString("wh"));
-		return s.toString();
-	}
+    /**
+     * Returns request parameters in old '++++' form.
+     * 
+     * @return String with parameters in old '++++' form.
+     */
+    public String getAsOldString() {
+        StringBuffer s = new StringBuffer(50);
+        s.append(getAsString("request.path"));
+        s.append(getAsString("fn"));
+        s.append("+" + getAsString("pn"));
+        s.append("+" + getAsString("ws"));
+        s.append("+" + getAsString("mo"));
+        s.append("+" + getAsString("mk"));
+        s.append("+" + getAsString("wx"));
+        s.append("+" + getAsString("wy"));
+        s.append("+" + getAsString("ww"));
+        s.append("+" + getAsString("wh"));
+        return s.toString();
+    }
 
-	/**
-	 * Set request parameters from javax.servlet.ServletRequest. Uses the
-	 * Requests getParameter methods for 'fn=foo' style parameters.
-	 * 
-	 * @param request
-	 *            ServletRequest to get parameters from.
-	 */
-	//@SuppressWarnings("unchecked") // ServletRequest.getParameterNames() returns naked Enumeration
+    /**
+     * Set request parameters from javax.servlet.ServletRequest. Uses the
+     * Requests getParameter methods for 'fn=foo' style parameters.
+     * 
+     * @param request
+     *            ServletRequest to get parameters from.
+     */
+    // @SuppressWarnings("unchecked") // ServletRequest.getParameterNames()
+    // returns naked Enumeration
     public void setWithParamRequest(ServletRequest request) {
-		setValue("servlet.request", request);
-		// go through all request parameters
-		for (Enumeration<String> i = request.getParameterNames(); i.hasMoreElements();) {
-			String name = (String) i.nextElement();
-			// is this a known parameter?
-			if (params.containsKey(name)) {
-				Parameter p = (Parameter) this.get(name);
-				// internal parameters are not set
-				if (p.getType() == 'i') {
-					continue;
-				}
-				p.setValueFromString(request.getParameter(name));
-				continue;
-			}
-			// unknown parameters are just added with type 'r'
-			newParameter(name, null, request.getParameter(name), 'r');
-		}
-		// add path from request
-		setValue("request.path", ((HttpServletRequest) request).getPathInfo());
-	}
+        setValue("servlet.request", request);
+        // go through all request parameters
+        for (Enumeration<String> i = request.getParameterNames(); i.hasMoreElements();) {
+            String name = (String) i.nextElement();
+            // is this a known parameter?
+            if (params.containsKey(name)) {
+                Parameter p = (Parameter) this.get(name);
+                // internal parameters are not set
+                if (p.getType() == 'i') {
+                    continue;
+                }
+                p.setValueFromString(request.getParameter(name));
+                continue;
+            }
+            // unknown parameters are just added with type 'r'
+            newParameter(name, null, request.getParameter(name), 'r');
+        }
+        // add path from request
+        setValue("request.path", ((HttpServletRequest) request).getPathInfo());
+    }
 
-	/**
-	 * Set request parameters from query string. Uses the separator string qs to
-	 * get 'fn=foo' style parameters.
-	 * 
-	 * @param qs
-	 *            query string
-	 * @param sep
-	 *            parameter-separator string
-	 */
-	public void setWithParamString(String qs, String sep) {
-		// go through all request parameters
-		String[] qa = qs.split(sep);
-		for (int i = 0; i < qa.length; i++) {
-			// split names and values on "="
-			String[] nv = qa[i].split("=");
-			try {
-				String name = URLDecoder.decode(nv[0], "UTF-8");
-				String val = URLDecoder.decode(nv[1], "UTF-8");
-				// is this a known parameter?
-				if (params.containsKey(name)) {
-					Parameter p = (Parameter) this.get(name);
-					// internal parameters are not set
-					if (p.getType() == 'i') {
-						continue;
-					}
-					p.setValueFromString(val);
-					continue;
-				}
-				// unknown parameters are just added with type 'r'
-				newParameter(name, null, val, 'r');
-			} catch (UnsupportedEncodingException e) {
-				// this shouldn't happen anyway
-				e.printStackTrace();
-			}
-		}
-	}
+    /**
+     * Set request parameters from query string. Uses the separator string qs to
+     * get 'fn=foo' style parameters.
+     * 
+     * @param qs
+     *            query string
+     * @param sep
+     *            parameter-separator string
+     */
+    public void setWithParamString(String qs, String sep) {
+        // go through all request parameters
+        String[] qa = qs.split(sep);
+        for (int i = 0; i < qa.length; i++) {
+            // split names and values on "="
+            String[] nv = qa[i].split("=");
+            try {
+                String name = URLDecoder.decode(nv[0], "UTF-8");
+                String val = URLDecoder.decode(nv[1], "UTF-8");
+                // is this a known parameter?
+                if (params.containsKey(name)) {
+                    Parameter p = (Parameter) this.get(name);
+                    // internal parameters are not set
+                    if (p.getType() == 'i') {
+                        continue;
+                    }
+                    p.setValueFromString(val);
+                    continue;
+                }
+                // unknown parameters are just added with type 'r'
+                newParameter(name, null, val, 'r');
+            } catch (UnsupportedEncodingException e) {
+                // this shouldn't happen anyway
+                e.printStackTrace();
+            }
+        }
+    }
 
-	/**
-	 * Test if option string <code>opt</code> is set. Checks if the substring
-	 * <code>opt</code> is contained in the options string <code>param</code>.
-	 * Deprecated! use hasOption(String opt) for "mo"-options.
-	 * 
-	 * @param opt
-	 *            Option string to be tested.
-	 * @return boolean
-	 */
-	public boolean hasOption(String param, String opt) {
-		String s = getAsString(param);
-		if (s != null) {
-			StringTokenizer i = new StringTokenizer(s, ",");
-			while (i.hasMoreTokens()) {
-				if (i.nextToken().equals(opt)) {
-					return true;
-				}
-			}
-		}
-		return false;
-	}
+    /**
+     * Test if option string <code>opt</code> is set. Checks if the substring
+     * <code>opt</code> is contained in the options string <code>param</code>.
+     * Deprecated! use hasOption(String opt) for "mo"-options.
+     * 
+     * @param opt
+     *            Option string to be tested.
+     * @return boolean
+     */
+    public boolean hasOption(String param, String opt) {
+        String s = getAsString(param);
+        if (s != null) {
+            StringTokenizer i = new StringTokenizer(s, ",");
+            while (i.hasMoreTokens()) {
+                if (i.nextToken().equals(opt)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
 
-	/**
-	 * The image file path to be accessed.
-	 * 
-	 * The mage file path is assembled from the servlets RequestPath and
-	 * Parameter fn and normalized.
-	 * 
-	 * @return String the effective filepath.
-	 */
-	public String getFilePath() {
-		String s = getAsString("request.path");
-		s += getAsString("fn");
-		return FileOps.normalName(s);
-	}
+    /**
+     * The image file path to be accessed.
+     * 
+     * The mage file path is assembled from the servlets RequestPath and
+     * Parameter fn and normalized.
+     * 
+     * @return String the effective filepath.
+     */
+    public String getFilePath() {
+        String s = getAsString("request.path");
+        s += getAsString("fn");
+        return FileOps.normalName(s);
+    }
 
-	/* Property getter and setter */
+    /* Property getter and setter */
 
-	/**
-	 * Set the requests base URL parameter from a
-	 * javax.sevlet.http.HttpServletRequest.
-	 * 
-	 * @param request
-	 *            HttpServletRequest to set the base URL.
-	 */
-	public void setBaseURL(javax.servlet.http.HttpServletRequest request) {
-		String baseURL = null;
-		// calculate base URL string from request (minus last part)
-		String s = request.getRequestURL().toString();
-		int eop = s.lastIndexOf("/");
-		if (eop > 0) {
-			baseURL = s.substring(0, eop);
-		} else {
-			// fall back
-			baseURL = "http://" + request.getServerName()
-					+ "/docuserver/digitallibrary";
-		}
-		setValue("base.url", baseURL);
-	}
+    /**
+     * Set the requests base URL parameter from a
+     * javax.sevlet.http.HttpServletRequest.
+     * 
+     * @param request
+     *            HttpServletRequest to set the base URL.
+     */
+    public void setBaseURL(javax.servlet.http.HttpServletRequest request) {
+        String baseURL = null;
+        // calculate base URL string from request (minus last part)
+        String s = request.getRequestURL().toString();
+        int eop = s.lastIndexOf("/");
+        if (eop > 0) {
+            baseURL = s.substring(0, eop);
+        } else {
+            // fall back
+            baseURL = "http://" + request.getServerName() + "/docuserver/digitallibrary";
+        }
+        setValue("base.url", baseURL);
+    }
 
-	/**
-	 * Returns the image.
-	 * 
-	 * @return DocuImage
-	 */
-	public DocuImage getImage() {
-		return image;
-	}
+    /**
+     * Returns the image.
+     * 
+     * @return DocuImage
+     */
+    public DocuImage getImage() {
+        return image;
+    }
 
-	/**
-	 * Sets the image.
-	 * 
-	 * @param image
-	 *            The image to set
-	 */
-	public void setImage(DocuImage image) {
-		this.image = image;
-		setValue("docu.image", image);
-	}
+    /**
+     * Sets the image.
+     * 
+     * @param image
+     *            The image to set
+     */
+    public void setImage(DocuImage image) {
+        this.image = image;
+        setValue("docu.image", image);
+    }
 
-	/**
-	 * @return
-	 */
-	public HttpServletRequest getServletRequest() {
-		return servletRequest;
-	}
+    /**
+     * @return
+     */
+    public HttpServletRequest getServletRequest() {
+        return servletRequest;
+    }
 
 }