/** * Append parameters to the uri. Each parameter is appended to the uri with "parameter=value", the * parameters are separated by "&". */ public static String appendParameters(String uri, Parameters parameters) { if (parameters != null) { StringBuffer buffer = new StringBuffer(uri); String[] keys = parameters.getNames(); String current; char separator = (uri.indexOf("?") == -1 ? '?' : '&'); if (keys != null) { for (int i = 0; i < keys.length; i++) { current = keys[i]; buffer .append(separator) .append(current) .append('=') .append(SourceUtil.encode(parameters.getParameter(current, null))); separator = '&'; } } return buffer.toString(); } return uri; }
/** Get the parameters for the logicsheet */ protected Map getLogicSheetParameters() { if (this.logicSheetParameters != null) { return this.logicSheetParameters; } HashMap map = null; if (par != null) { String[] params = par.getNames(); if (params != null) { for (int i = 0; i < params.length; i++) { String name = params[i]; if (isValidXSLTParameterName(name)) { String value = par.getParameter(name, null); if (value != null) { if (map == null) { map = new HashMap(params.length); } map.put(name, value); } } } } } if (this._useParameters) { Request request = ObjectModelHelper.getRequest(objectModel); Enumeration parameters = request.getParameterNames(); if (parameters != null) { while (parameters.hasMoreElements()) { String name = (String) parameters.nextElement(); if (isValidXSLTParameterName(name)) { String value = request.getParameter(name); if (map == null) { map = new HashMap(); } map.put(name, value); } } } } if (this._useSessionInfo) { final Request request = ObjectModelHelper.getRequest(objectModel); if (map == null) { map = new HashMap(6); } final Session session = request.getSession(false); if (session != null) { map.put("session-available", "true"); map.put("session-is-new", BooleanUtils.toStringTrueFalse(session.isNew())); map.put( "session-id-from-cookie", BooleanUtils.toStringTrueFalse(request.isRequestedSessionIdFromCookie())); map.put( "session-id-from-url", BooleanUtils.toStringTrueFalse(request.isRequestedSessionIdFromURL())); map.put( "session-valid", BooleanUtils.toStringTrueFalse(request.isRequestedSessionIdValid())); map.put("session-id", session.getId()); } else { map.put("session-available", "false"); } } if (this._useCookies) { Request request = ObjectModelHelper.getRequest(objectModel); Cookie cookies[] = request.getCookies(); if (cookies != null) { for (int i = 0; i < cookies.length; i++) { String name = cookies[i].getName(); if (isValidXSLTParameterName(name)) { String value = cookies[i].getValue(); if (map == null) { map = new HashMap(cookies.length); } map.put(name, value); } } } } this.logicSheetParameters = map; return this.logicSheetParameters; }