[Jspmyadmin-devs] CVS: jspmyadmin/src/com/jspmyadmin ConnectionPoolManager.java,NONE,1.1 config.prop
Brought to you by:
zsolyfree
Update of /cvsroot/jspmyadmin/jspmyadmin/src/com/jspmyadmin In directory usw-pr-cvs1:/tmp/cvs-serv27090/src/com/jspmyadmin Added Files: ConnectionPoolManager.java config.properties jspMyAdminConfig.java jspMyAdminLogWriter.java jspMyAdminUtil.java jspMyAdminVar.java Log Message: Some re order to the CVS to make it build with ANT im preparing the build.xml and properties now, so in a week it maybe ready to workr --- NEW FILE: ConnectionPoolManager.java --- /** * Copyright(c) 2001 iSavvix Corporation (http://www.isavvix.com/) * * All rights reserved * * Permission to use, copy, modify and distribute this material for * any purpose and without fee is hereby granted, provided that the * above copyright notice and this permission notice appear in all * copies, and that the name of iSavvix Corporation not be used in * advertising or publicity pertaining to this material without the * specific, prior written permission of an authorized representative of * iSavvix Corporation. * * ISAVVIX CORPORATION MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES, * EXPRESS OR IMPLIED, WITH RESPECT TO THE SOFTWARE, INCLUDING, BUT * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR ANY PARTICULAR PURPOSE, AND THE WARRANTY AGAINST * INFRINGEMENT OF PATENTS OR OTHER INTELLECTUAL PROPERTY RIGHTS. THE * SOFTWARE IS PROVIDED "AS IS", AND IN NO EVENT SHALL ISAVVIX CORPORATION OR * ANY OF ITS AFFILIATES BE LIABLE FOR ANY DAMAGES, INCLUDING ANY * LOST PROFITS OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES RELATING * TO THE SOFTWARE. * */ package com.jspmyadmin; import java.util.*; import java.sql.*; /** * Manages a java.sql.Connection pool. * * @author Anil Hemrajani */ public class ConnectionPoolManager { private Vector connections = new Vector(10); private Vector urls = new Vector(10); private String _driver = null, _url = null, _user = null, _password = null; private boolean _traceOn = false; private boolean initialized = false; private int _openConnections = 10; public ConnectionPoolManager() {} public void setDriver(String driver) { _driver = driver; } public void setDbURL(String url) { _url = url; } public void setUser(String user) { _user = user; } public void setPassword(String password) { _password = password; } /** Use this method to set the maximum number of open connections before unused connections are closed. */ public void setOpenConnectionCount(int count) { _openConnections = count; } public void setEnableTrace(boolean enable) { _traceOn = enable; } /** Returns a Vector of java.sql.Connection objects */ public Vector getConnectionList() { return connections; } public Vector getUrlList() { return urls; } /** Opens specified "count" of connections and adds them to the existing pool */ public synchronized void setInitOpenConnections(int count) throws SQLException { Connection c = null; ConnectionObject co = null; for (int i=0; i < count; i++) { c = createConnection(); co = new ConnectionObject(c, false); connections.addElement(co); urls.addElement(this._url); trace("ConnectionPoolManager: Adding new DB connection to pool (" + connections.size() + ")"); } } /** Returns a count of open connections */ public int getConnectionCount() { return connections.size(); } /** Returns an unused existing or new connection. */ public synchronized Connection getConnection() throws Exception { if (!initialized) { Class c = Class.forName(_driver); DriverManager.registerDriver((Driver)c.newInstance()); initialized = true; } Connection c = null; ConnectionObject co = null; boolean badConnection = false; for (int i=0; i < connections.size(); i++) { co = (ConnectionObject)connections.elementAt(i); // If connection is not in use, test to ensure it's still valid! if (!co.inUse) { try { badConnection = co.connection.isClosed(); if (!badConnection) badConnection = (co.connection.getWarnings() != null); } catch (Exception e) { badConnection = true; e.printStackTrace(); } // Connection is bad, remove from pool if (badConnection) { connections.removeElementAt(i); trace("ConnectionPoolManager: Remove disconnected DB connection #" + i); continue; } c = co.connection; co.inUse = true; trace("ConnectionPoolManager: Using existing DB connection #" + (i+1)); break; } } if (c == null) { c = createConnection(); co = new ConnectionObject(c, true); connections.addElement(co); urls.addElement(_url); trace("ConnectionPoolManager: Creating new DB connection #" + connections.size()); } return c; } /** Marks a flag in the ConnectionObject to indicate this connection is no longer in use */ public synchronized void releaseConnection(Connection c) { if (c == null) return; ConnectionObject co = null; for (int i=0; i < connections.size(); i++) { co = (ConnectionObject)connections.elementAt(i); if (c == co.connection) { co.inUse = false; break; } } for (int i=0; i < connections.size(); i++) { co = (ConnectionObject)connections.elementAt(i); if ((i+1) > _openConnections && !co.inUse) removeConnection(co.connection); } } /** Marks a flag in the ConnectionObject to indicate this connection is no longer in use */ public synchronized void removeConnection(Connection c) { if (c == null) return; ConnectionObject co = null; for (int i=0; i < connections.size(); i++) { co = (ConnectionObject)connections.elementAt(i); if (c == co.connection) { try { c.close(); connections.removeElementAt(i); trace("Removed " + c.toString()); } catch (Exception e) { e.printStackTrace(); } break; } } } private Connection createConnection() throws SQLException { Connection con = null; try { if (_user == null) _user = ""; if (_password == null) _password =""; Properties props = new Properties(); props.put("user", _user); props.put("password", _password); con = DriverManager.getConnection(_url, props); } catch (Throwable t) { throw new SQLException(t.getMessage()); } return con; } /** Closes all connections and clears out the connection pool */ public void releaseFreeConnections() { trace("ConnectionPoolManager.releaseFreeConnections()"); Connection c = null; ConnectionObject co = null; for (int i=0; i < connections.size(); i++) { co = (ConnectionObject)connections.elementAt(i); if (!co.inUse) removeConnection(co.connection); } } /** Closes all connections and clears out the connection pool */ public void finalize() { trace("ConnectionPoolManager.finalize()"); Connection c = null; ConnectionObject co = null; for (int i=0; i < connections.size(); i++) { co = (ConnectionObject)connections.elementAt(i); try { co.connection.close(); } catch (Exception e) { e.printStackTrace(); } co = null; } connections.removeAllElements(); } private void trace(String s) { if (_traceOn) System.err.println(s); } /** Test driver. */ /* public static void main(String args[]) throws Exception { String dbDriver = "org.gjt.mm.mysql.Driver", dbURL = "jdbc:mysql://localhost/test", dbUser = "root", dbPassword = ""; ConnectionPoolManager cm = new ConnectionPoolManager(); cm.setDriver(dbDriver); cm.setDbURL(dbURL); cm.setUser(dbUser); cm.setPassword(dbPassword); cm.setEnableTrace(true); cm.setOpenConnectionCount(2); Connection c = cm.getConnection(), c2 = cm.getConnection(), c3 = cm.getConnection(), c4 = cm.getConnection(); cm.releaseConnection(c2); cm.releaseConnection(c3); cm.releaseConnection(c4); System.out.println("Connection count = " + cm.getConnectionCount()); Statement s = c.createStatement(); ResultSet rs = s.executeQuery("SHOW DATABASES"); while(rs.next()) System.out.println(rs.getString(1)); rs.close(); s.close(); cm.releaseConnection(c); }*/ } class ConnectionObject { public java.sql.Connection connection = null; public boolean inUse = false; public ConnectionObject(Connection c, boolean useFlag) { connection = c; inUse = useFlag; } } --- NEW FILE: config.properties --- /* $Id: config.properties,v 1.1 2002/07/26 03:51:47 aalmenar Exp $ */ /* * phpMyAdmin Configuration File * All directives are explained in Documentation.html */ // You can disable a server config entry by setting host to ''. // MySQL hostname host=localhost // MySQL port - leave blank for default port port= // Use advanced authentication? adv_auth=false // MySQL standard user (only needed with advanced auth) stduser=cox // MySQL standard password (only needed with advanced auth) stpass=root // MySQL user (only needed with basic auth) user=root // MySQL password (only needed with basic auth) password= // If set to a db-name, only this db is accessible only_db=test // Verbose name for this host - leave blank to show the hostname verbose=myserver host1=cox port1= adv_auth1=false stduser1=root stpass1= user1=root password1= only_db1= verbose1=second //You can put any {host,port...verbose} as you want but don't forget to //numerate them correctly cfgManualBase = http://www.mysql.com/documentation/mysql/bychapter/ cfgConfirm = true cfgBorder = 0 cfgThBgcolor = #D3DCE3 cfgBgcolorOne = #CCCCCC cfgBgcolorTwo = #DDDDDD cfgMaxRows = 30 cfgMaxInputsize = 300px cfgOrder = ASC cfgShowBlob = true cfgShowSQL = true --- NEW FILE: jspMyAdminConfig.java --- /* * jspMyAdminConfig.java 0.6 2001/08/25 * Copyright (c) 2001 zso...@ya... under the GPL (www.gnu.org/copyleft/) * * TERMS OF USAGE: * This file was written and developed by Zsolt Mali (zso...@ya...) * for educational and demonstration purposes only. You have all rights to use, * modify, and redistribute this file as you like. The only * requirement is that you must retain this notice, without modifications, at * the top of your source code. No warranties or guarantees are expressed or * implied. DO NOT use this code in a production environment without * understanding the limitations and weaknesses pretaining to or caused by the * use of these scripts, directly or indirectly. USE AT YOUR OWN RISK! */ package com.jspmyadmin; import java.util.*; public class jspMyAdminConfig { /** * Class description goes here. * * @version 0.9 2001/07/09 21:01:36 PM * @author Zsolt Mali */ Hashtable servers = new Hashtable(); int nofservers = 0; /** * constructor DSJspUtils * * @author Zsolt Mali * @param source the Hashtable with the config file key, value pairs */ public jspMyAdminConfig ( Hashtable source) { this.servers = source; init(); }//end constructor --> jspMyAdminConfig /** * Makes the initializations and set the static variables * * * @author Zsolt Mali */ public void init() { int i = 1; this.nofservers = ( (this.servers.containsKey("host")) && (!this.servers.get("host").equals("")) ) ? (this.nofservers+1) : this.nofservers; while ( this.servers.containsKey("host"+i) ) { this.nofservers = ( (this.servers.containsKey("host"+i)) && (!this.servers.get("host"+i).equals("")) ) ? (this.nofservers+1) : this.nofservers; i++; } }//end method --> public void init() /** * Makes the initializations and set the static variables * * * @author Zsolt Mali */ public int getNumberOfServers() { return this.nofservers; }//end method --> public void getNumberOfServers() /** * Getting the value for the specified key for the specified server * (default we getting the first key) * * @author Zsolt Mali * @param localkey the key from config * @param number the number from config */ public String get4Server( String localkey, int number) { if ( number>0 ) { return (String)this.servers.get(localkey+number); } else if ( number == 0) { return (String)this.servers.get(localkey); } else { return ""; } }//end method --> public String get4Server( String localkey, int number ) /** * Getting the value for the specified key * * @author Zsolt Mali * @param key the key which value we are looking for */ public Object get( Object key ) { return this.servers.get( key ); }//end method --> public Object get( Object key ) /** * Returning the value for the specified key as String * * @author Zsolt Mali * @param key the key which value we are looking for */ public String get( String key ) { return (String)this.servers.get( key ); }//end method --> public Object get( Object key ) /** * Returns the value for the specified key as Integer * * @author Zsolt Mali * @param key the key which value we are looking for */ public int getInt( Object key ) throws NumberFormatException { return Integer.parseInt((String)this.servers.get( key )); }//end method --> public int get( Object key ) /** * Appends a new key value pair to hashtable * * * @author Zsolt Mali * @param key the key * @param value */ public void set( Object key, Object value ) { this.servers.put( key, value); }//end method --> public void set( Object key, Object value) /** * Appends a new key value pair to hashtable * * * @author Zsolt Mali * @param key the key * @param value */ public void set( String key, String value ) { this.servers.put( key, value); }//end method --> public void set( Object key, Object value) }//end class --> jspMyAdminConfig --- NEW FILE: jspMyAdminLogWriter.java --- /* * jspMyAdminLogWriter 0.6 2001/08/25 * Copyright (c) 2001 zso...@ya... under the GPL (www.gnu.org/copyleft/) * * TERMS OF USAGE: * This file was written and developed by Zsolt Mali (zso...@ya...) * for educational and demonstration purposes only. You have all rights to use, * modify, and redistribute this file as you like. The only * requirement is that you must retain this notice, without modifications, at * the top of your source code. No warranties or guarantees are expressed or * implied. DO NOT use this code in a production environment without * understanding the limitations and weaknesses pretaining to or caused by the * use of these scripts, directly or indirectly. USE AT YOUR OWN RISK! */ package com.jspmyadmin; import java.io.*; import java.text.SimpleDateFormat; import java.util.Calendar; import java.net.InetAddress; public class jspMyAdminLogWriter { PrintWriter out; String IPAdress; public jspMyAdminLogWriter(String log_FileName) { try { out = new PrintWriter(new FileWriter(log_FileName,true)); } catch (IOException e) { System.out.println("File not found"+log_FileName); } try { InetAddress me = InetAddress.getLocalHost(); this.IPAdress=me.getHostAddress(); } catch (Exception e) { e.printStackTrace(); } }//end method jspMyAdminLogWriter public jspMyAdminLogWriter(String log_FileName, String ipAddress) { try { out = new PrintWriter(new FileWriter(log_FileName,true)); } catch (IOException e) { System.out.println("File not found"+log_FileName); } this.IPAdress=ipAddress; }//end method jspMyAdminLogWriter public void writeln(String line) { Calendar rightNow = Calendar.getInstance(); SimpleDateFormat df = new SimpleDateFormat("(E dd MMM yyyy HH:mm:ss a)"); out.println(df.format(rightNow.getTime())+" - "+IPAdress+" - "+line); out.flush(); } //end method writeln public void close() { out.flush(); out.close(); } //end method close }//end class jspMyAdminLogWriter --- NEW FILE: jspMyAdminUtil.java --- /* * jspMyAdminUtil.java 0.6 2001/08/25 * Copyright (c) 2001 zso...@ya... under the GPL (www.gnu.org/copyleft/) * * TERMS OF USAGE: * This file was written and developed by Zsolt Mali (zso...@ya...) * for educational and demonstration purposes only. You have all rights to use, * modify, and redistribute this file as you like. The only * requirement is that you must retain this notice, without modifications, at * the top of your source code. No warranties or guarantees are expressed or * implied. DO NOT use this code in a production environment without * understanding the limitations and weaknesses pretaining to or caused by the * use of these scripts, directly or indirectly. USE AT YOUR OWN RISK! */ package com.jspmyadmin; public class jspMyAdminUtil { /** * Class description goes here. * * @version 0.9 2001/06/29 * @author Zsolt Mali */ /** * constructor jspMyAdminUtil */ public jspMyAdminUtil() { }//end constructor --> jspMyAdminUtil() /** * Converts > < & " into html equivalents > < & " from a source * string and returns it. * * @author Zsolt Mali * @param source the source string */ public static String htmlSpecialChars(String source) { if (source == null) { return ""; } StringBuffer dest= new StringBuffer(source.length()); for (int i=0;i<source.length() ;i++ ) { char c; c=source.charAt(i); if (c=='>') { dest.append(">"); } else if (c=='<') { dest.append("<"); } else if (c=='&') { dest.append("&"); } else if (c=='"') { dest.append("""); } else { dest.append(c); } } return dest.toString(); }//end method --> public String htmlSpecialChars(String source) /** * Converts \n into html equivalents <br> from a source * string and returns it. * (new line to break) * * @author Zsolt Mali * @param source the source string */ public static String nl2Br(String source) { if (source == null) { return ""; } StringBuffer dest= new StringBuffer(source.length()); for (int i=0;i<source.length() ;i++ ) { char c; c=source.charAt(i); if (c=='\n') { dest.append("<br>"); } else { dest.append(c); } } return dest.toString(); }//end method --> public String nl2Br(String source) /** * Converts ',",\,NUL into sql equivalents \',\",\\,\NUL from a source * string and returns it. * (new line to break) * * @author Zsolt Mali * @param source the source string */ public static String addSlashes(String source) { if (source == null) { return ""; } StringBuffer dest= new StringBuffer(source.length()); for (int i=0;i<source.length() ;i++ ) { char c; c=source.charAt(i); if (c=='"') { dest.append("\\\""); } else if (c=='\'') { dest.append("\\\'"); } else if (c=='\\') { dest.append("\\\\"); } else if ((c=='N') && ((i+2)<source.length()) && (source.charAt(i+1) == 'U') && (source.charAt(i+2) == 'L')) { dest.append("\\N"); } else { dest.append(c); } } return dest.toString(); }//end method --> public String addSlashes(String source) /** * Converts sql \',\",\\,\NUL into ',",\,NUL from a source * string and returns it. * (new line to break) * * @author Zsolt Mali * @param source the source string */ public static String stripSlashes(String source) { if (source == null) { return ""; } StringBuffer dest= new StringBuffer(source.length()); for (int i=0;i<source.length() ;i++ ) { char c; c=source.charAt(i); if ( (c=='\\') && (i+1<source.length()) && ( source.charAt(i+1)=='\'') ) { dest.append("\'"); i++; } else if ( (c=='\\') && (i+1<source.length()) && ( source.charAt(i+1)=='\"') ) { dest.append("\""); i++; } else if ( (c=='\\') && ((i+3)<source.length()) && (source.charAt(i+1) == 'N') && (source.charAt(i+2) == 'U') && (source.charAt(i+3) == 'L') ) { dest.append("N"); i++; } else if ( (c=='\\') && (i+1<source.length()) && ( source.charAt(i+1)=='\\') ) { dest.append("\\"); i++; } else { dest.append(c); } } return dest.toString(); }//end method --> public String nl2Br(String source) /** * Converts a string to integer. If fails is not throwing a * NumberFormatException, instead return 0. * * @author Zsolt Mali * @param source the source string */ public static int toInt(String source) { try { return Integer.parseInt(source); } catch(NumberFormatException notint) { return 0; } }//end method --> public int toInt(String source) /** * Replace in a String the last occurence of another String with a replacement * string. * This occurence must to be at the end of the source. * * @author Zsolt Mali * @param source the source string * @param occurence the occurence string * @param replacement the replacement string */ public static String replaceLast(String source, String occurence, String replacement) { if (source.lastIndexOf(occurence)==source.length()-occurence.length()) { return source.substring(0,source.lastIndexOf(occurence)) + replacement; } else { return source; } }//end method --> public static String replaceLast(String source, String occurence, String replacement) /** * Replace in a String all occurence of another String with a replacement * string. * * @author Zsolt Mali * @param source the source string * @param occurence the occurence string * @param replacement the replacement string */ public static String replaceAll(String source, String occurence, String replacement) { while (source.indexOf(occurence)!=-1) { source = source.substring(0,source.indexOf(occurence)) + replacement +source.substring(source.indexOf(occurence)+occurence.length(), source.length()); } return source; }//end method --> public static String replaceAll(String source, String occurence, String replacement) /** * Replace in a String a Substring with a replacement * starting from a specified Substring or char (begin) * until other specified Substring or char (end). * * @author Zsolt Mali * @param source the source string * @param begin the begin substring * @param end the end substring * @param replacement the replacement string */ public static String replaceFromStrToStr(String source, String begin, String end, String replacement) { while ( (source.indexOf(begin)!=-1) && (source.indexOf(end)!=-1) && (source.indexOf(begin)<source.indexOf(end)) ) { source = source.substring(0,source.indexOf(begin)) + replacement +source.substring(source.indexOf(end)+end.length(), source.length()); } return source; }//end method --> public static String replaceFromStrToStr(String source, String begin, String end, String replacement) }//end class --> public class jspMyAdminUtil --- NEW FILE: jspMyAdminVar.java --- /* * jspMyAdminVar.java 0.6 2001/08/25 * Copyright (c) 2001 zso...@ya... under the GPL (www.gnu.org/copyleft/) * * TERMS OF USAGE: * This file was written and developed by Zsolt Mali (zso...@ya...) * for educational and demonstration purposes only. You have all rights to use, * modify, and redistribute this file as you like. The only * requirement is that you must retain this notice, without modifications, at * the top of your source code. No warranties or guarantees are expressed or * implied. DO NOT use this code in a production environment without * understanding the limitations and weaknesses pretaining to or caused by the * use of these scripts, directly or indirectly. USE AT YOUR OWN RISK! */ package com.jspmyadmin; import java.util.*; import java.io.*; import javax.servlet.*; import javax.servlet.jsp.*; import javax.servlet.http.*; public class jspMyAdminVar { /** * Class description goes here. * * @version 0.9 2001/07/02 23:22:28 * @author Zsolt Mali */ Hashtable parameters = new Hashtable(); PageContext page ; /** * constructor jspMyAdminVar * * @author Zsolt Mali * @param page the PageContext object of the current page */ public jspMyAdminVar ( PageContext pagesource) { this.page=pagesource; reLoad(); }//end constructor --> jspMyAdminVar /** * ReLoad all the existent parameters from a page * * * @author Zsolt Mali */ public void reLoad() { this.parameters.clear(); parseParameters( this.page, this.page.SESSION_SCOPE ); parseParameters( this.page); parseParameters( this.page.getRequest() ); }//end method --> public void reLoad() /** * this is for testing scope only * * * @author Zsolt Mali */ public void test() { Enumeration e=retKeys(); while ( e.hasMoreElements() ) { try { Object key = e.nextElement(); this.page.getOut().println((String)key + "=" + get( key ).toString() + "<br>"); } catch (IOException ex) { System.out.println("Unable to write"); } } }//end method --> public void test() /** * Return all the keys from the Hashtable * * * @author Zsolt Mali */ public Enumeration retKeys() { return this.parameters.keys(); }//end method --> public Enumeration retKeys() /** * Return all the values from the Hashtable * * * @author Zsolt Mali */ public Enumeration retValues() { return this.parameters.elements(); }//end method --> public Enumeration retValues() /** * Return true if the specified key exist in the parameters * else return false * * * @author Zsolt Mali * @param key the searched key */ public boolean existKey( Object key ) { return this.parameters.containsKey( key ); }//end method --> public boolean existKey() /** * Return true if the specified value exist in the parameters * else return false * * * @author Zsolt Mali * @param value the searched value */ public boolean existValue( Object value ) { return this.parameters.contains( value ); }//end method --> public boolean existValue() /** * Return true if the specified key exist in the parameters and his value is not "" or null * else return false * * * @author Zsolt Mali * @param value the searched value */ public boolean notEmpty( Object key ) { if ( (this.parameters.containsKey( key )) && (get(key)!=null) && (!((Object)get(key)).toString().equals(""))) { return true; } return false; }//end method --> public boolean existValue() /** * If exist the specified key in the list returns his value, else returns null * * * @author Zsolt Mali * @param key the searched key */ public Object get( Object key ) { if ( this.parameters.containsKey( key ) != false ) { return this.parameters.get( key ); } else { return null; } }//end method --> public Object get() /** * If exist the specified key in the list returns his String value, else returns null * * * @author Zsolt Mali * @param key the searched key */ public String get( String key ) { if ( this.parameters.containsKey( key ) != false ) { return (String)this.parameters.get( key ); } else { return null; } }//end method --> public Object get() /** * If exist the specified key in the list returns his int value, else returns null * * * @author Zsolt Mali * @param key the searched key */ public int getInt( String key ) throws NumberFormatException { if ( this.parameters.containsKey( key ) != false ) { return Integer.parseInt((String)this.parameters.get( key )); } else { return 0; } }//end method --> public Object get() /** * Append a new key --> value pair to hashtable * * * @author Zsolt Mali * @param key the key * @param value the value of the key */ public void set( Object key, Object value ) { this.parameters.put( key, value); }//end method --> public void set( Object key, Object value) /** * Append a new key --> value pair to hashtable and to request object * * * @author Zsolt Mali * @param key the key * @param value the value of the key */ public void setRequestAttribute( String key, Object value ) { this.parameters.put( key, value); this.page.getRequest().setAttribute(key , value); }//end method --> public void setRequestAttribute( Object key, Object value) /** * Parse the request object of the PageContext and makes/adds keys and * value pairs to a Hashtable * * @author Zsolt Mali * @param request the request object */ public void parseParameters(ServletRequest request) { Enumeration en = request.getAttributeNames(); while ( en.hasMoreElements() ) { String name = (String)en.nextElement(); Object value = request.getAttribute(name); if ( value != null ) { parameters.put(name,value); } } Enumeration enum = request.getParameterNames(); while ( enum.hasMoreElements() ) { String name = (String)enum.nextElement(); String value = request.getParameter(name); if ( !value.equals("") ) { parameters.put(name,value); } } }//end method --> public void parseParameters(ServletRequest request) /** * Parse the session object of a PageContext and makes/adds keys and * to a Hashtable * * @author Zsolt Mali * @param session the session object */ public void parseParameters( HttpSession session ) { String[] enum = session.getValueNames(); for (int i=0 ; i<enum.length ; i++ ) { String name = enum[i]; Object value = session.getValue(name); if ( value != null ) { parameters.put(name,value); } } }//end method --> public void parseParameters( HttpSession session ) /** * Parse the PageContext and makes/adds attributenames and values * to a Hashtable * * @author Zsolt Mali * @param page the PageContext object */ public void parseParameters( PageContext page ) { Enumeration enum = page.getAttributeNamesInScope(page.PAGE_SCOPE); while ( enum.hasMoreElements() ) { String name = (String)enum.nextElement(); Object value = page.getAttribute(name); if ( value != null ) { parameters.put(name,value); } } }//end method --> public void parseParameters( page session ) /** * Parse the PageContext and makes/adds attributenames and values * to a Hashtable * * @author Zsolt Mali * @param page the PageContext object */ public void parseParameters( PageContext page, int scope ) { Enumeration enum = page.getAttributeNamesInScope(scope); while ( enum.hasMoreElements() ) { String name = (String)enum.nextElement(); Object value = page.getAttribute(name , scope); if ( value != null ) { parameters.put(name,value); } } }//end method --> public void parseParameters( page session ) }//end class jspMyAdminVar |