[validator] Help Regarding Commons Validator to use it in servlets/jsp application
Dear all, I am a good programmer and I also had SCJP 1.5 but unfortunately have not worked on Java for a long time. At the moment I want to know how can we use commons validator in a simple servlet or jsp application without any other framework like struts, spring or jsf. Can anyone point me to the correct place where I can see this. I have actually searched on the commons validator wiki and other places but could not find an example or documentation explaining this in particular. Perhaps my inexperience is one reason that I could not use this commons validator based on the official documentation available. I am quite hopeful that I will get a good and helpful response soon. Regards, Asif
[validator] Help Regarding Commons Validator to use it in servlets/jsp application
Thank you very much Mohammad nour El-Din. I am taking a look at the recommended link. Can you answer a few short questions. 1. Do we always need a bean based validation. I believe in this scenario we must have to create a bean based on our form post 2. Can we also use a validation framework or more appropriately is there a validation framework which we can instantiate inside our servlet methods and feed our form input data into it for validation. Regards, Asif On Wed, Nov 10, 2010 at 5:16 PM, Mohammad Nour El-Din nour.moham...@gmail.com wrote: Hey :) Take a look at this http://incubator.apache.org/bval/cwiki/index.html this is the new standard based Bean-Validation framework for both JSE and JEE. On Wed, Nov 10, 2010 at 11:41 AM, Muhammad Asif muasi...@gmail.com wrote: Dear all, I am a good programmer and I also had SCJP 1.5 but unfortunately have not worked on Java for a long time. At the moment I want to know how can we use commons validator in a simple servlet or jsp application without any other framework like struts, spring or jsf. Can anyone point me to the correct place where I can see this. I have actually searched on the commons validator wiki and other places but could not find an example or documentation explaining this in particular. Perhaps my inexperience is one reason that I could not use this commons validator based on the official documentation available. I am quite hopeful that I will get a good and helpful response soon. Regards, Asif -- Thanks - Mohammad Nour Author of (WebSphere Application Server Community Edition 2.0 User Guide) http://www.redbooks.ibm.com/abstracts/sg247585.html - LinkedIn: http://www.linkedin.com/in/mnour - Blog: http://tadabborat.blogspot.com Life is like riding a bicycle. To keep your balance you must keep moving - Albert Einstein Writing clean code is what you must do in order to call yourself a professional. There is no reasonable excuse for doing anything less than your best. - Clean Code: A Handbook of Agile Software Craftsmanship Stay hungry, stay foolish. - Steve Jobs - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [validator] Help Regarding Commons Validator to use it in servlets/jsp application
Ok thanks for your kind help though. I will look for these there. On Wed, Nov 10, 2010 at 5:59 PM, Mohammad Nour El-Din nour.moham...@gmail.com wrote: Please ask these question on the user mailing of Apache Bean Validation :) . On Wed, Nov 10, 2010 at 12:54 PM, Muhammad Asif muasi...@gmail.com wrote: Thank you very much Mohammad nour El-Din. I am taking a look at the recommended link. Can you answer a few short questions. 1. Do we always need a bean based validation. I believe in this scenario we must have to create a bean based on our form post 2. Can we also use a validation framework or more appropriately is there a validation framework which we can instantiate inside our servlet methods and feed our form input data into it for validation. Regards, Asif On Wed, Nov 10, 2010 at 5:16 PM, Mohammad Nour El-Din nour.moham...@gmail.com wrote: Hey :) Take a look at this http://incubator.apache.org/bval/cwiki/index.html this is the new standard based Bean-Validation framework for both JSE and JEE. On Wed, Nov 10, 2010 at 11:41 AM, Muhammad Asif muasi...@gmail.com wrote: Dear all, I am a good programmer and I also had SCJP 1.5 but unfortunately have not worked on Java for a long time. At the moment I want to know how can we use commons validator in a simple servlet or jsp application without any other framework like struts, spring or jsf. Can anyone point me to the correct place where I can see this. I have actually searched on the commons validator wiki and other places but could not find an example or documentation explaining this in particular. Perhaps my inexperience is one reason that I could not use this commons validator based on the official documentation available. I am quite hopeful that I will get a good and helpful response soon. Regards, Asif -- Thanks - Mohammad Nour Author of (WebSphere Application Server Community Edition 2.0 User Guide) http://www.redbooks.ibm.com/abstracts/sg247585.html - LinkedIn: http://www.linkedin.com/in/mnour - Blog: http://tadabborat.blogspot.com Life is like riding a bicycle. To keep your balance you must keep moving - Albert Einstein Writing clean code is what you must do in order to call yourself a professional. There is no reasonable excuse for doing anything less than your best. - Clean Code: A Handbook of Agile Software Craftsmanship Stay hungry, stay foolish. - Steve Jobs - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org -- Thanks - Mohammad Nour Author of (WebSphere Application Server Community Edition 2.0 User Guide) http://www.redbooks.ibm.com/abstracts/sg247585.html - LinkedIn: http://www.linkedin.com/in/mnour - Blog: http://tadabborat.blogspot.com Life is like riding a bicycle. To keep your balance you must keep moving - Albert Einstein Writing clean code is what you must do in order to call yourself a professional. There is no reasonable excuse for doing anything less than your best. - Clean Code: A Handbook of Agile Software Craftsmanship Stay hungry, stay foolish. - Steve Jobs - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: DBCP - unclosed connections
On 11/8/10 7:19 PM, Tyson Lowery wrote: I have a JSP page that is getting reported for not closing connections in catalina.out. I'm running Tomcat 6.0.26, so I believe we are on DBCP 1.2. I've racked my brain trying to figure out how these connections could possible remain unclosed. Does anyone have any tips or suggestions on how I can further troubleshoot this? If your page holds onto a connection for longer than 55 seconds or there are queries taking longer than 55 seconds to execute, DBCP will consider the associated connection abandoned. Try increasing this setting. Note also that maxWait is specified in milliseconds, so below is a pretty low setting. Phil Here's the latest version of our connection pool settings: Resource name=jdbc/myDB auth=Container type=javax.sql.DataSource maxActive=350 maxIdle=40 minIdle=10 maxWait=45 removeAbandoned=true removeAbandonedTimeout=55 validationQuery=select 1 testWhileIdle=true testOnBorrow=true logAbandoned=true timeBetweenEvictionRunsMillis=10 minEvictableIdleTimeMillis=40 numTestsPerEvictionRun=3 username=user password=password driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://1.2.3.4/myDB?autoReconnect=trueamp;jdbcCompliantTruncation=false/ The JSP page literally has everything enclosed in a try block and all connections closed in a finally statement. See below: Connection con = null; Statement stmt = null; ResultSet rset = null; String query = ; Statement stmt2 = null; ResultSet rset3 = null; try { // page executes } catch (SQLException ex) { out.println (\n*** SQLException caught ***\n); while (ex != null) { out.println (SQLState: + ex.getSQLState ()); out.println (Message: + ex.getMessage ()); out.println (Vendor: + ex.getErrorCode ()); ex = ex.getNextException (); out.println (); } } catch (java.lang.Exception ex) { // Got some other type of exception. Dump it. ex.printStackTrace (); } finally { if(rset != null) { try {rset.close();} catch(Exception e) { System.out.println(Exception in finally rset); e.printStackTrace(); } rset = null; } if(rset3 != null) { try {rset3.close();} catch(Exception e) { System.out.println(Exception in finally rset3); e.printStackTrace(); } rset3 = null; } if(stmt != null) { try {stmt.close();} catch(Exception e) { System.out.println(Exception in finally stmt); e.printStackTrace(); } stmt = null; } if(stmt2 != null) { try {stmt2.close();} catch(Exception e) { System.out.println(Exception in finally stmt2); e.printStackTrace(); } stmt2 = null; } if(con != null) { try {con.close();} catch(Exception e) { System.out.println(Exception in finally con); e.printStackTrace(); } con = null; } } - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [validator] Help Regarding Commons Validator to use it in servlets/jsp application
No problem :), I am sorry I have no direct answers to your questions this is why BeanValidation User Mailing list is the right place go look at :). On Wed, Nov 10, 2010 at 1:01 PM, Muhammad Asif muasi...@gmail.com wrote: Ok thanks for your kind help though. I will look for these there. On Wed, Nov 10, 2010 at 5:59 PM, Mohammad Nour El-Din nour.moham...@gmail.com wrote: Please ask these question on the user mailing of Apache Bean Validation :) . On Wed, Nov 10, 2010 at 12:54 PM, Muhammad Asif muasi...@gmail.com wrote: Thank you very much Mohammad nour El-Din. I am taking a look at the recommended link. Can you answer a few short questions. 1. Do we always need a bean based validation. I believe in this scenario we must have to create a bean based on our form post 2. Can we also use a validation framework or more appropriately is there a validation framework which we can instantiate inside our servlet methods and feed our form input data into it for validation. Regards, Asif On Wed, Nov 10, 2010 at 5:16 PM, Mohammad Nour El-Din nour.moham...@gmail.com wrote: Hey :) Take a look at this http://incubator.apache.org/bval/cwiki/index.html this is the new standard based Bean-Validation framework for both JSE and JEE. On Wed, Nov 10, 2010 at 11:41 AM, Muhammad Asif muasi...@gmail.com wrote: Dear all, I am a good programmer and I also had SCJP 1.5 but unfortunately have not worked on Java for a long time. At the moment I want to know how can we use commons validator in a simple servlet or jsp application without any other framework like struts, spring or jsf. Can anyone point me to the correct place where I can see this. I have actually searched on the commons validator wiki and other places but could not find an example or documentation explaining this in particular. Perhaps my inexperience is one reason that I could not use this commons validator based on the official documentation available. I am quite hopeful that I will get a good and helpful response soon. Regards, Asif -- Thanks - Mohammad Nour Author of (WebSphere Application Server Community Edition 2.0 User Guide) http://www.redbooks.ibm.com/abstracts/sg247585.html - LinkedIn: http://www.linkedin.com/in/mnour - Blog: http://tadabborat.blogspot.com Life is like riding a bicycle. To keep your balance you must keep moving - Albert Einstein Writing clean code is what you must do in order to call yourself a professional. There is no reasonable excuse for doing anything less than your best. - Clean Code: A Handbook of Agile Software Craftsmanship Stay hungry, stay foolish. - Steve Jobs - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org -- Thanks - Mohammad Nour Author of (WebSphere Application Server Community Edition 2.0 User Guide) http://www.redbooks.ibm.com/abstracts/sg247585.html - LinkedIn: http://www.linkedin.com/in/mnour - Blog: http://tadabborat.blogspot.com Life is like riding a bicycle. To keep your balance you must keep moving - Albert Einstein Writing clean code is what you must do in order to call yourself a professional. There is no reasonable excuse for doing anything less than your best. - Clean Code: A Handbook of Agile Software Craftsmanship Stay hungry, stay foolish. - Steve Jobs - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org -- Thanks - Mohammad Nour Author of (WebSphere Application Server Community Edition 2.0 User Guide) http://www.redbooks.ibm.com/abstracts/sg247585.html - LinkedIn: http://www.linkedin.com/in/mnour - Blog: http://tadabborat.blogspot.com Life is like riding a bicycle. To keep your balance you must keep moving - Albert Einstein Writing clean code is what you must do in order to call yourself a professional. There is no reasonable excuse for doing anything less than your best. - Clean Code: A Handbook of Agile Software Craftsmanship Stay hungry, stay foolish. - Steve Jobs - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: DBCP - unclosed connections
Thanks Phil for the reply. I've changed maxWait to 1000 and removeAbandonedTimeout to 300. MySQL wait_timeout is set to 500. I've put some System.out.printlns in and can see that this page is taking less than 1 second to process, even in the cases where I get the DBCP object created 2010-11-10 12:54:14 by the following code was never closed: java.lang.Exception errors. So I don't think the timeout is being hit. I can also see that the finally block is being executed, I'm now printing to catalina.out after each object is closed. Note that this isn't being reported everytime the page loads, just once in a while. Are there cases where this exception is generated even though the connections were successfully closed? Or is there a way to get more info from AbandonedTrace.java? Thanks, Tyson On 11/10/2010 2:44 AM, Phil Steitz wrote: On 11/8/10 7:19 PM, Tyson Lowery wrote: I have a JSP page that is getting reported for not closing connections in catalina.out. I'm running Tomcat 6.0.26, so I believe we are on DBCP 1.2. I've racked my brain trying to figure out how these connections could possible remain unclosed. Does anyone have any tips or suggestions on how I can further troubleshoot this? If your page holds onto a connection for longer than 55 seconds or there are queries taking longer than 55 seconds to execute, DBCP will consider the associated connection abandoned. Try increasing this setting. Note also that maxWait is specified in milliseconds, so below is a pretty low setting. Phil Here's the latest version of our connection pool settings: Resource name=jdbc/myDB auth=Container type=javax.sql.DataSource maxActive=350 maxIdle=40 minIdle=10 maxWait=45 removeAbandoned=true removeAbandonedTimeout=55 validationQuery=select 1 testWhileIdle=true testOnBorrow=true logAbandoned=true timeBetweenEvictionRunsMillis=10 minEvictableIdleTimeMillis=40 numTestsPerEvictionRun=3 username=user password=password driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://1.2.3.4/myDB?autoReconnect=trueamp;jdbcCompliantTruncation=false/ The JSP page literally has everything enclosed in a try block and all connections closed in a finally statement. See below: Connection con = null; Statement stmt = null; ResultSet rset = null; String query = ; Statement stmt2 = null; ResultSet rset3 = null; try { // page executes } catch (SQLException ex) { out.println (\n*** SQLException caught ***\n); while (ex != null) { out.println (SQLState: + ex.getSQLState ()); out.println (Message: + ex.getMessage ()); out.println (Vendor: + ex.getErrorCode ()); ex = ex.getNextException (); out.println (); } } catch (java.lang.Exception ex) { // Got some other type of exception. Dump it. ex.printStackTrace (); } finally { if(rset != null) { try {rset.close();} catch(Exception e) { System.out.println(Exception in finally rset); e.printStackTrace(); } rset = null; } if(rset3 != null) { try {rset3.close();} catch(Exception e) { System.out.println(Exception in finally rset3); e.printStackTrace(); } rset3 = null; } if(stmt != null) { try {stmt.close();} catch(Exception e) { System.out.println(Exception in finally stmt); e.printStackTrace(); } stmt = null; } if(stmt2 != null) { try {stmt2.close();} catch(Exception e) { System.out.println(Exception in finally stmt2); e.printStackTrace(); } stmt2 = null; } if(con != null) { try {con.close();} catch(Exception e) { System.out.println(Exception in finally con); e.printStackTrace(); } con = null; } } - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [IO] tailer sample code
2010/11/10 Sébastien Roux roux.sebast...@gmail.com: I'm not a Java specialist but quite curious about the new tailer classes in commons IO 2.0. Now what does this mean : TailerListener listener = ... Its just an abbreviation to show the line is not complete. You have to create your own TailerListener implementation which does whatever you want with the lines added to the file. So for example you could do something like the following: /** * TailerListener implementation. */ public class ShowLinesListener extends TailerListenerAdapter { @Override public void handle(String line) { System.out.println(line); } } Then create the Tailer with your implementation: TailerListener listener = new ShowLinesListener(); Tailer tailer = Tailer.create(file, listener, delay); http://commons.apache.org/io/api-release/org/apache/commons/io/input/Tailer.html Niall I mean what I am supposed to put after the equal? Would you have a quick example regarding basic file tailing implementation? I also checked this without getting the picture = http://permalink.gmane.org/gmane.comp.jakarta.commons.scm/9636 Many thanks for any guidance you may provide. Sébastien Roux mail: roux.sebast...@gmail.com - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: DBCP - unclosed connections
I will check or someone else can confirm DBCP and pool versions. If not the latest you can upgrade them independently of Tomcat and you should try that. See the Tomcat datasource docs for instructions on how to do this. Ask here or on tomcat-user if you need help. The answer to your question is no, so if this is happening it indicates a DBCP or pool bug or something else happening in your code to hold the connections. Phil On Nov 10, 2010, at 1:39 PM, Tyson Lowery tysonlow...@gmail.com wrote: Thanks Phil for the reply. I've changed maxWait to 1000 and removeAbandonedTimeout to 300. MySQL wait_timeout is set to 500. I've put some System.out.printlns in and can see that this page is taking less than 1 second to process, even in the cases where I get the DBCP object created 2010-11-10 12:54:14 by the following code was never closed: java.lang.Exception errors. So I don't think the timeout is being hit. I can also see that the finally block is being executed, I'm now printing to catalina.out after each object is closed. Note that this isn't being reported everytime the page loads, just once in a while. Are there cases where this exception is generated even though the connections were successfully closed? Or is there a way to get more info from AbandonedTrace.java? Thanks, Tyson On 11/10/2010 2:44 AM, Phil Steitz wrote: On 11/8/10 7:19 PM, Tyson Lowery wrote: I have a JSP page that is getting reported for not closing connections in catalina.out. I'm running Tomcat 6.0.26, so I believe we are on DBCP 1.2. I've racked my brain trying to figure out how these connections could possible remain unclosed. Does anyone have any tips or suggestions on how I can further troubleshoot this? If your page holds onto a connection for longer than 55 seconds or there are queries taking longer than 55 seconds to execute, DBCP will consider the associated connection abandoned. Try increasing this setting. Note also that maxWait is specified in milliseconds, so below is a pretty low setting. Phil Here's the latest version of our connection pool settings: Resource name=jdbc/myDB auth=Container type=javax.sql.DataSource maxActive=350 maxIdle=40 minIdle=10 maxWait=45 removeAbandoned=true removeAbandonedTimeout=55 validationQuery=select 1 testWhileIdle=true testOnBorrow=true logAbandoned=true timeBetweenEvictionRunsMillis=10 minEvictableIdleTimeMillis=40 numTestsPerEvictionRun=3 username=user password=password driverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://1.2.3.4/myDB?autoReconnect=trueamp;jdbcCompliantTruncation=false/ The JSP page literally has everything enclosed in a try block and all connections closed in a finally statement. See below: Connection con = null; Statement stmt = null; ResultSet rset = null; String query = ; Statement stmt2 = null; ResultSet rset3 = null; try { // page executes } catch (SQLException ex) { out.println (\n*** SQLException caught ***\n); while (ex != null) { out.println (SQLState: + ex.getSQLState ()); out.println (Message: + ex.getMessage ()); out.println (Vendor: + ex.getErrorCode ()); ex = ex.getNextException (); out.println (); } } catch (java.lang.Exception ex) { // Got some other type of exception. Dump it. ex.printStackTrace (); } finally { if(rset != null) { try {rset.close();} catch(Exception e) { System.out.println(Exception in finally rset); e.printStackTrace(); } rset = null; } if(rset3 != null) { try {rset3.close();} catch(Exception e) { System.out.println(Exception in finally rset3); e.printStackTrace(); } rset3 = null; } if(stmt != null) { try {stmt.close();} catch(Exception e) { System.out.println(Exception in finally stmt); e.printStackTrace(); } stmt = null; } if(stmt2 != null) { try {stmt2.close();} catch(Exception e) { System.out.println(Exception in finally stmt2); e.printStackTrace(); } stmt2 = null; } if(con != null) { try {con.close();} catch(Exception e) { System.out.println(Exception in finally con); e.printStackTrace(); } con = null; } } - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org