RE: Help/Examples setting up security settings2
scenario 2 allow me to access my page as I would expect to? Obviously, I don't know diddly-squat about how this technology works and is meant to be used. Everything I try ends up either a drop dead failure or confuses me even more than I already was. There does not seem to be any consistency to the behaviors I've been seeing. If someone asked me right now whether to recommend using JSP, I'd have to say No. I can't even get a simple test scenario to work. I'm trying to hold off on buying any books on the subject, because I'm not sure which ones would be the best to get (although I have some ideas) and more importantly, because I am trying to evaluate the technology and the feasibility (not to mention the do-ability) of potentially converting an existing ASP application to JSP. The books would be purchased through my department, and I don't want to have a bunch of books bought that I may end up not using, if the decision ends up being that we won't go the JSP route. I realize that it's difficult for someone reading this to get the full picture of my situation. I've tried to include all pertinent information. If anyone can help me out, I would sure appreciate it. (Thanks again Frank Zammetti for the information you've provided so far.) Thanks, Joe Gagnon - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help/Examples setting up security settings2
Although I don't think this is the source of your problem, it strikes me as odd to be protecting the root of your webapp when this is where the unprotected page are as well (i.e., login.jsp, login_error.html) [Gagnon, Joseph M] What can I say, I don't know much about what I'm doing. That is a good idea. Didn't think it would matter much for such a simple test. Not a problem, we all go through a learning phase :) I'm not sure it would matter either frankly, but it seems like it might... if you request environment.jsp, the security intercept happens and tries to redirect to login.jsp, but that itself is protected, so ANOTHER intercept happens, etc. I'm not sure that will happen mind you, but I could imagine it happening, and your caught in a loop. Even if it is smart enough to avoid it there, what happens if you enter your password wrong and it tries to go to login_error.jsp? Same thing maybe, since it's protected too. Since I don't know for sure what will happen, better to avoid the unknown I figure :) Actually, one other thing... the references to the login form and the login error page in the login-config element I believe are relative to the webapp root, so drop the Simple_JSP from the beginning of them so they are /login.jsp and /login_error.jsp respectively. [Gagnon, Joseph M] How important is the leading slash? IIRC, it is required. I don't want to say what the difference is with or without it because I'm not 100% sure it's right, but the bottom line is I am reasonably sure uit has to be there. Again, not sure this is the problem, but it could be. [Gagnon, Joseph M] Hmm. That's an interesting point. I wasn't sure how the path rules worked here. (i.e. whether you need to specify from the server root (e.g. webapps) or if it was more from the specific webapp's root. From what you're saying, it's the latter. Right, it's all context-relative, and the context is whatever webapp you are in, NOT the server root (in essence you can think there is no server root really, that will simplify it a bit... pretend whatever webapp your working on is all there is and you should be OK). Also, there are perhaps some other things you need to do to tell Tomcat to use security... anyone else, does Joseph need to do anything to set up the UserDatabase resource[Gagnon, Joseph M] I have no idea what this is., or is that set up by default? In server.xml, there is a GlobalNamingResources element... in here should be a definition for UserDatabase. I *think* it is there by default, but I was hoping someone else could confirm. There is also an engine element, and within this can be a context element, one for each webapp. It is not strictly required, but it allows you to set various things. It looks like the engine has to be made aware of the UserDatabase, via a realm element. This is Tomcat-specific stuff, and while I've hacked my way through it before, there must be someone reading this that can better guide you with this particular part of the equation. It may be set up by default, it may not, I don't know. Frank - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: A little offbeat question
Yeah, as others have said, JAVA can't find your classs. Either add the directory the class file is in to your classpath, or just execute: java -cp . HelloWorld That will add the current directory to the classpath for the current execution. Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies www.omnytex.com From: John Najarian [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: A little offbeat question Date: Thu, 16 Sep 2004 00:00:52 -0700 I tried to run a program I thought would but it doesn't. This is on a windows XP platform. Everything compiled well but I get this error: Exception in thread main java.lang.NoClassDefFoundError: HelloWorld/class So I went back and tried a no brainer 'HelloWorld' This is the code. /** * The HelloWorld class implements an application that * displays Hello World! to the standard output. */ public class HelloWorld { public static void main(String[] args) { // Display Hello World! System.out.println(Hello World!); } } It compiles but I get the same error. I check my environment variables and mine are JAVA_HOME c:\j2sdk1.4.2_03 PATH C:\Perl\bin\;C:\j2sdk1.4.2_03\bin\;C:\j2sdkee1.3.1\bin\;%SystemRoot%\system3 2;%SystemRoot%;%SystemRoot%\system32\WBEM Any ideas? Thanks in advance _ Get ready for school! Find articles, homework help and more in the Back to School Guide! http://special.msn.com/network/04backtoschool.armx - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: RE: A little offbeat question
That's usually what I do, just add . to the classpath. That way you can execute a class in the current directory wherever you are (which of course comes up frequently when trying to test some minor thing on it's own) Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies www.omnytex.com From: John Najarian [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Subject: RE: RE: A little offbeat question Date: Thu, 16 Sep 2004 01:02:59 -0700 Thanks, the '-cp .' did it. Something is definitely hosed up. I haven't installed anything so I'm thinking it may be a virus although I have scanned my PC with newest definitions. I'm still going to look at the CLASSPATH env var. Maybe I should add '.' to the CLASSPATH variable. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, September 16, 2004 12:40 AM To: Tomcat Users List Subject: Re: RE: A little offbeat question But the exception says NoClassDefFoundError: HelloWorld/class. So where does the /class come from?? In any case don't bother with classpath environment, but (with the class in your current directory) simply run 'java -cp . HelloWorld'. Would really surprise me if it didn't work. John Najarian [EMAIL PROTECTED] schrieb am 16.09.2004, 09:32:18: That's what I did. When I was first learning Java that 1 bit me. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, September 16, 2004 12:24 AM To: Tomcat Users List Subject: Re: A little offbeat question Try running 'java ... HelloWorld' instead of 'java ... HelloWorld.class' :-) Regards, Martin John Najarian schrieb am 16.09.2004, 09:00:52: I tried to run a program I thought would but it doesn't. This is on a windows XP platform. Everything compiled well but I get this error: Exception in thread main java.lang.NoClassDefFoundError: HelloWorld/class So I went back and tried a no brainer 'HelloWorld' This is the code. /** * The HelloWorld class implements an application that * displays Hello World! to the standard output. */ public class HelloWorld { public static void main(String[] args) { // Display Hello World! System.out.println(Hello World!); } } It compiles but I get the same error. I check my environment variables and mine are JAVA_HOME c:\j2sdk1.4.2_03 PATH C:\Perl\bin\;C:\j2sdk1.4.2_03\bin\;C:\j2sdkee1.3.1\bin\;%SystemRoot%\system3 2;%SystemRoot%;%SystemRoot%\system32\WBEM Any ideas? Thanks in advance -- Martin Schaefer NAXOS Software Solutions GmbH i.G. Herrenstr. 1 69502 Hemsbach Germany Phone:+49 (0) 6201 49298-2 Mobile: +49 (0) 172 6269246 Fax: +49 (0) 6201 49298-1 Mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Martin Schaefer NAXOS Software Solutions GmbH i.G. Herrenstr. 1 69502 Hemsbach Germany Phone:+49 (0) 6201 49298-2 Mobile: +49 (0) 172 6269246 Fax: +49 (0) 6201 49298-1 Mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ FREE pop-up blocking with the new MSN Toolbar get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: A little offbeat question
I wish they would clarify that, to, Don't set CLASSPATH yourself. Let the applications or frameworks do that. I think that would be less confusing. As I understand it, this simply means that if you are going to execute a Java app, you should set the classpath right before executing the app (on the command line really). Likewise, when you compile, construct the classpath on the command line of javac. Or, when running Tomcat or something like that, let it's startup scripts create the classpath. At least in Windows, all those situations would result in a local classpath, i.e., if you have three command prompt windows open, one to do compiles, one to execute apps directly and one to run Tomcat in, all three can basically set up their own classpath, completely independent of one another. I think this is what that statement is talking about. Frank _ Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Tomcat 5 SSL problem
Hello all. I'm trying to get SSL working on my Tomcat 5.0.27 instance... I've read all the how-to's and spent an hour Googling, but I can't get past an issue I'm having... I have the following entry in my server.xml: Connector className=org.apache.coyote.tomcat5.CoyoteConnector port=8443 minProcessors=5 maxProcessors=75 enableLookups=true acceptCount=100 debug=0 scheme=https secure=true useURIValidationHack=false disableUploadTimeout=true Factory className=org.apache.coyote.tomcat5.CoyoteServerSocketFactory keystoreFile=c:\tomcat\.keystore keystorePass=my_password clientAuth=false protocol=TLS / /Connector The keystore file is there, and I believe generated properly, as per the how-to instructions. When I start Tomcat however, I get the following exception: [INFO] Http11Protocol - Initializing Coyote HTTP/1.1 on http-8181 [ERROR] Http11Protocol - Error initializing socket factory java.lang.ClassNotFo undException: Can't find any SSL implementationjava.lang.ClassNotFoundException : Can't find any SSL implementation at org.apache.tomcat.util.net.SSLImplementation.getInstance(SSLImplement ation.java:57) at org.apache.tomcat.util.net.SSLImplementation.getInstance(SSLImplement ation.java:63) at org.apache.coyote.http11.Http11Protocol.checkSocketFactory(Http11Prot ocol.java:770) at org.apache.coyote.http11.Http11Protocol.init(Http11Protocol.java:119) at org.apache.coyote.tomcat5.CoyoteConnector.initialize(CoyoteConnector. java:1429) at org.apache.catalina.core.StandardService.initialize(StandardService.j ava:609) at org.apache.catalina.core.StandardServer.initialize(StandardServer.jav a:2384) at org.apache.catalina.startup.Catalina.load(Catalina.java:507) at org.apache.catalina.startup.Catalina.load(Catalina.java:528) at java.lang.reflect.Method.invoke(Native Method) at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:247) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:421) [ERROR] Catalina - Catalina.start LifecycleException: Protocol handler initial ization failed: java.lang.ClassNotFoundException: Can't find any SSL implementat ionLifecycleException: Protocol handler initialization failed: java.lang.Class NotFoundException: Can't find any SSL implementation at org.apache.coyote.tomcat5.CoyoteConnector.initialize(CoyoteConnector. java:1431) at org.apache.catalina.core.StandardService.initialize(StandardService.j ava:609) at org.apache.catalina.core.StandardServer.initialize(StandardServer.jav a:2384) at org.apache.catalina.startup.Catalina.load(Catalina.java:507) at org.apache.catalina.startup.Catalina.load(Catalina.java:528) at java.lang.reflect.Method.invoke(Native Method) at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:247) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:421) Tomcat DOES continue to run, but obviously without SSL working. Any ideas? Thanks all! Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies www.omnytex.com _ Get ready for school! Find articles, homework help and more in the Back to School Guide! http://special.msn.com/network/04backtoschool.armx - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Server JVM with service startup
Hello all. I have a Tomcat 5.0.18 instance that runs as a Windows service. I have been unable to figure out how to start it with the server JVM (heck, it could be starting that way now, but I didn't do anything to tell it to do so). I've checked through numerous docs and books, all of them give some info (just a little bit!) about using that JVM when starting it from the command line, but I've found nothing addressing how to do so when it's a service. Anyone point me in the right direction? Thanks! Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies www.omnytex.com _ Is your PC infected? Get a FREE online computer virus scan from McAfee® Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Server JVM with service startup
Yeah, I looked into the possibility of making it part of the startup command as QM suggests, but that doesn't seem possible, as Matt says. Matt, do you have a name for that tool that I can Google for? Even something close might get me to it in a few minutes... Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies www.omnytex.com From: Dale, Matt [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: RE: Server JVM with service startup Date: Tue, 17 Aug 2004 17:41:04 +0100 Nope, you have to put all the settings in the registry, there is a tool that you can get that does this for you but I'm not sure on where to get it. -Original Message- From: QM [mailto:[EMAIL PROTECTED] Sent: 17 August 2004 17:37 To: Tomcat Users List Subject: Re: Server JVM with service startup On Tue, Aug 17, 2004 at 12:31:33PM -0400, Frank Zammetti wrote: : Hello all. I have a Tomcat 5.0.18 instance that runs as a Windows service. : I have been unable to figure out how to start it with the server JVM (heck, : it could be starting that way now, but I didn't do anything to tell it to : do so). I'm going out on a limb here, since I'm not fluent in Windows, but how do you start the service? Does Windows call startup.bat or some other batch file where you could set the proper environment variables (JAVA_OPTS=-server)? -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] InterScan_Disclaimer.txt - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ On the road to retirement? Check out MSN Life Events for advice on how to get there! http://lifeevents.msn.com/category.aspx?cid=Retirement - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Server JVM with service startup
Thank you Matt! Unfortunately, that web site's downloads doesn't seem to be working, they all just bring me to a blank page. Argh. Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies www.omnytex.com From: Dale, Matt [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: RE: Server JVM with service startup Date: Tue, 17 Aug 2004 17:49:48 +0100 I can do better, here's the URL http://web.bvu.edu/staff/david/index.jsp?section=softwaresubsection=tcservcfgpage=overview -Original Message- From: Frank Zammetti [mailto:[EMAIL PROTECTED] Sent: 17 August 2004 17:45 To: [EMAIL PROTECTED] Subject: RE: Server JVM with service startup Yeah, I looked into the possibility of making it part of the startup command as QM suggests, but that doesn't seem possible, as Matt says. Matt, do you have a name for that tool that I can Google for? Even something close might get me to it in a few minutes... Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies www.omnytex.com From: Dale, Matt [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: RE: Server JVM with service startup Date: Tue, 17 Aug 2004 17:41:04 +0100 Nope, you have to put all the settings in the registry, there is a tool that you can get that does this for you but I'm not sure on where to get it. -Original Message- From: QM [mailto:[EMAIL PROTECTED] Sent: 17 August 2004 17:37 To: Tomcat Users List Subject: Re: Server JVM with service startup On Tue, Aug 17, 2004 at 12:31:33PM -0400, Frank Zammetti wrote: : Hello all. I have a Tomcat 5.0.18 instance that runs as a Windows service. : I have been unable to figure out how to start it with the server JVM (heck, : it could be starting that way now, but I didn't do anything to tell it to : do so). I'm going out on a limb here, since I'm not fluent in Windows, but how do you start the service? Does Windows call startup.bat or some other batch file where you could set the proper environment variables (JAVA_OPTS=-server)? -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] InterScan_Disclaimer.txt - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ On the road to retirement? Check out MSN Life Events for advice on how to get there! http://lifeevents.msn.com/category.aspx?cid=Retirement - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] InterScan_Disclaimer.txt - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ On the road to retirement? Check out MSN Life Events for advice on how to get there! http://lifeevents.msn.com/category.aspx?cid=Retirement - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Log rotation HOWTO
I haven't been able to find a clear answer to this anywhere online, hopefully you fine folks can help... I need a way to rotate my stdout log in Tomcat 5.0.18. It could be dalily or weekly (monthly might be OK too). Is thre any way to do this? I assume so, so how? Thanks in advance all! _ Get fast, reliable Internet access with MSN 9 Dial-up now 3 months FREE! http://join.msn.click-url.com/go/onm00200361ave/direct/01/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to check if a String is empty?
I've always done if (test == null || test.trim().equalsIgnoreCase()) { } (I'm anal about always using equalsIgnoreCase unless I know for sure that case sensitivity is required). No need to do anything more complex than that in my experience. Always do the simplest thing that will work. Frank From: Robert Bateman [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Re: how to check if a String is empty? Date: Fri, 18 Jun 2004 12:58:30 -0400 Wouldn't test.trim().length() be a better test? length() after trm would tell you if non white-space was left. Bob On Thursday 24 June 2004 12:30 pm, Peter Guyatt wrote: Hi There, You could do the check test.length() 0 Pete -Original Message- From: Carl Olivier [mailto:[EMAIL PROTECTED] Sent: 24 June 2004 17:18 To: 'Tomcat Users List' Subject: RE: how to check if a String is empty? There is a trim() funtion in java.lang.String ? -Original Message- From: Marten Lehmann [mailto:[EMAIL PROTECTED] Sent: 24 June 2004 06:20 PM To: 'Tomcat Users List' Subject: how to check if a String is empty? Hello, maybe this is not the perfect group for my question, but as my problem appears at the development of JSPs and tomcat is concerned with that, I hope you can answer it. I often see the condition String test = req.getParameter(test); if (test == null) { /* string is empty */ } else { /* string contains something */ } But if test contains just blanks and other whitespaces, it's not null, but doesn't contain usable data anyhow. How can I check if a string contains whitespaces only? I though of something like if (test == null || test.trim().equals()) { } but there's no trim()-function, right? How do you solve this problem? With whitespaces I mean blanks, tabs and newlines. Regards Marten - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Make the most of your family vacation with tips from the MSN Family Travel Guide! http://dollar.msn.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to check if a String is empty?
Depends I guess :) I personally find the use of a magic number to be more complex. To my eyes, it's clearer to see an empty string. The intention is more clear. Kind of a silly debate I suppose because neither is exactly rocket science ;) From: Robert F. Hall [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Re: how to check if a String is empty? Date: Thu, 24 Jun 2004 10:22:06 -0700 Howdy, if (test == null || test.trim().length() == 0 ) { } is simpler. /Robert Frank Zammetti wrote: I've always done if (test == null || test.trim().equalsIgnoreCase()) { } (I'm anal about always using equalsIgnoreCase unless I know for sure that case sensitivity is required). No need to do anything more complex than that in my experience. Always do the simplest thing that will work. Frank From: Robert Bateman [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Re: how to check if a String is empty? Date: Fri, 18 Jun 2004 12:58:30 -0400 Wouldn't test.trim().length() be a better test? length() after trm would tell you if non white-space was left. Bob On Thursday 24 June 2004 12:30 pm, Peter Guyatt wrote: Hi There, You could do the check test.length() 0 Pete -Original Message- From: Carl Olivier [mailto:[EMAIL PROTECTED] Sent: 24 June 2004 17:18 To: 'Tomcat Users List' Subject: RE: how to check if a String is empty? There is a trim() funtion in java.lang.String ? -Original Message- From: Marten Lehmann [mailto:[EMAIL PROTECTED] Sent: 24 June 2004 06:20 PM To: 'Tomcat Users List' Subject: how to check if a String is empty? Hello, maybe this is not the perfect group for my question, but as my problem appears at the development of JSPs and tomcat is concerned with that, I hope you can answer it. I often see the condition String test = req.getParameter(test); if (test == null) { /* string is empty */ } else { /* string contains something */ } But if test contains just blanks and other whitespaces, it's not null, but doesn't contain usable data anyhow. How can I check if a string contains whitespaces only? I though of something like if (test == null || test.trim().equals()) { } but there's no trim()-function, right? How do you solve this problem? With whitespaces I mean blanks, tabs and newlines. Regards Marten - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Make the most of your family vacation with tips from the MSN Family Travel Guide! http://dollar.msn.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ FREE pop-up blocking with the new MSN Toolbar get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to check if a String is empty?
That's a good question, and one to which I do not know the answer. My HUNCH is that, as you say, modern compilers would deal with that easy enough. I could be very wrong though. Anyone happen to know for sure? From: Robert Bateman [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Re: how to check if a String is empty? Date: Fri, 18 Jun 2004 13:21:09 -0400 Frank, NOT questioning your solution, but doesn't the call to equalsIgnoreCase() cause a temp String object to be created and destroyed? Or do todays JIT compilers handle that case effectively? Bob On Thursday 24 June 2004 01:16 pm, Frank Zammetti wrote: I've always done if (test == null || test.trim().equalsIgnoreCase()) { } (I'm anal about always using equalsIgnoreCase unless I know for sure that case sensitivity is required). No need to do anything more complex than that in my experience. Always do the simplest thing that will work. Frank - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ MSN Movies - Trailers, showtimes, DVD's, and the latest news from Hollywood! http://movies.msn.click-url.com/go/onm00200509ave/direct/01/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: list active sessions.
I don't see that behavior. Is there a setting in Tomcat to turn that function on and off perhaps? None of my sessions survive a Tomcat restart, so I've never had to deal with this. Frank From: Radek Liebzeit [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Subject: RE: list active sessions. Date: Wed, 23 Jun 2004 07:51:08 +0200 Really nice. I am just wondering about one thing - about persistent sessions. I have a session counter based on the SessionListeners. It is increased when some session is created and decreased when the session is destroyed. So, when I restart the Tomcat server some sessions are recreated but counter state doesn't. Therefore, after session timeout, the counter status is negative. It's not problem for me, it is enough for my purposes. I am just wondering how do you solve this behaviour? Radek -Original Message- From: Frank Zammetti [mailto:[EMAIL PROTECTED] Sent: Monday, June 21, 2004 3:45 PM To: [EMAIL PROTECTED] Subject: RE: list active sessions. I spent a couple of days last week implementing just such a thing, so I feel qualified to answer :) There is no easy way to do it. There USED to be a SessionContext object available in the servlet spec that would allow you to do a lot of cool things with sessions, but it was removed as of spec 2.1 I think because Sun believed it to be a security risk. Unfortunately there was nothing added to take it's place. The way you have to do this, or at least one way (the only way I found) is to track it yourself. First, I already had an AppConfig object that contains a static HashMap. This has a bunch of config values for my app loaded from a config file at startup. I then added an activeSessions HashMap to that class. Create a similar class for yourself, along the lines of the following: import java.util.HashMap; public class AppConfig { private static HashMap activeUsers = null; public static HashMap activeUsers() { return activeUsers; } public static void setActiveUsers(HashMap inActiveUsers) { activeUsers = inActiveUsers; } } Then, create a SessionListener something like the following: package com.mycompany.myapp; import java.util.HashMap; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionListener; public class SessionListener implements HttpSessionListener { public void sessionCreated(HttpSessionEvent se) { HashMap activeUsers = (HashMap)AppConfig.getActiveUsers(); synchronized (activeUsers) { activeUsers.put(se.getSession().getId(), new HashMap()); } } public void sessionDestroyed(HttpSessionEvent se) { HashMap activeUsers = (HashMap)AppConfig.getActiveUsers(); synchronized (appConfig) { activeUsers.remove(se.getSession().getId()); } } } Then just add the following to web.xml after your servlet section: listener listener-classcom.mycompany.myapp.SessionListener/listener-class /listener Basically, every time a session is created, you'll get an entry in the activeUsers HashMap keyed by sessionID, and the record will be removed when the session is destroyed. Further, what I do is that when my logon Action is called, when the user is validated I add some information for that user into the HashMap (first name, last name, logon time, etc). This allows me to have a pretty nice little tracking display in my app. The one problem you run into with this is that if the user just closes the browser window rather than using your nice logout function, the session lingers until the timeout period elapses. I didn't like that! My app is frames-based, and I already had one hidden frame, so I added the following to the body tag of that frame's source document: onUnload=openLogoffPopup(); ... and then the openLogoffPopup() function: function openLogoffPopup() { windowHandle = window.open(, , width=200,height=1,top=1,left=1); str = + html + head + title + /title + /head; str += + body onLoad=\window.location='%=request.getContextPath() + /app/logoff.app%';\; str += + table width=\100%\ height=\100%\ border=\0\; str += + tr + td align=\center\ valign=\middle\; str += + span style=\color:#00;font-family:arial;font-size:11pt;font- weight:bold;\; str += Logging out of application... + /span; str += + /td + /tr; str += + /table; str += + /body + /html; windowHandle.document.write(str); windowHandle.document.close(); } That calls the logoff Action whcih does not much more than session.invalidate(). This works well in IE, I do not know if it is cross-browser though (not a concern for my company). It should work fine to add this to all your JSP's, assuming your app isn't frame-based, I think it'll work just the same. But, maybe you can live with the session lingering if the window
RE: list active sessions.
How would the counter persist? Even assuming the sessions persist (something I don't see, even though I know the sessions are fully serializable), the counter as I previously described is in-memory as part of a static class. Are you talking about modifying it to use a database? In that case, yes, I agree the counter should then persist as well. Frank From: Jacob Kjome [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: RE: list active sessions. Date: Wed, 23 Jun 2004 15:10:31 + Quoting Frank Zammetti [EMAIL PROTECTED]: I don't see that behavior. Is there a setting in Tomcat to turn that function on and off perhaps? None of my sessions survive a Tomcat restart, so I've never had to deal with this. Tomcat will dump session objects which don't implement Serializable or are marked as such, but fail serialization for whatever reason. Make sure objects are serializable and the counter will persist across restarts (as long as the session hasn't already timed out). Jake Frank From: Radek Liebzeit [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Subject: RE: list active sessions. Date: Wed, 23 Jun 2004 07:51:08 +0200 Really nice. I am just wondering about one thing - about persistent sessions. I have a session counter based on the SessionListeners. It is increased when some session is created and decreased when the session is destroyed. So, when I restart the Tomcat server some sessions are recreated but counter state doesn't. Therefore, after session timeout, the counter status is negative. It's not problem for me, it is enough for my purposes. I am just wondering how do you solve this behaviour? Radek -Original Message- From: Frank Zammetti [mailto:[EMAIL PROTECTED] Sent: Monday, June 21, 2004 3:45 PM To: [EMAIL PROTECTED] Subject: RE: list active sessions. I spent a couple of days last week implementing just such a thing, so I feel qualified to answer :) There is no easy way to do it. There USED to be a SessionContext object available in the servlet spec that would allow you to do a lot of cool things with sessions, but it was removed as of spec 2.1 I think because Sun believed it to be a security risk. Unfortunately there was nothing added to take it's place. The way you have to do this, or at least one way (the only way I found) is to track it yourself. First, I already had an AppConfig object that contains a static HashMap. This has a bunch of config values for my app loaded from a config file at startup. I then added an activeSessions HashMap to that class. Create a similar class for yourself, along the lines of the following: import java.util.HashMap; public class AppConfig { private static HashMap activeUsers = null; public static HashMap activeUsers() { return activeUsers; } public static void setActiveUsers(HashMap inActiveUsers) { activeUsers = inActiveUsers; } } Then, create a SessionListener something like the following: package com.mycompany.myapp; import java.util.HashMap; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionListener; public class SessionListener implements HttpSessionListener { public void sessionCreated(HttpSessionEvent se) { HashMap activeUsers = (HashMap)AppConfig.getActiveUsers(); synchronized (activeUsers) { activeUsers.put(se.getSession().getId(), new HashMap()); } } public void sessionDestroyed(HttpSessionEvent se) { HashMap activeUsers = (HashMap)AppConfig.getActiveUsers(); synchronized (appConfig) { activeUsers.remove(se.getSession().getId()); } } } Then just add the following to web.xml after your servlet section: listener listener-classcom.mycompany.myapp.SessionListener/listener-class /listener Basically, every time a session is created, you'll get an entry in the activeUsers HashMap keyed by sessionID, and the record will be removed when the session is destroyed. Further, what I do is that when my logon Action is called, when the user is validated I add some information for that user into the HashMap (first name, last name, logon time, etc). This allows me to have a pretty nice little tracking display in my app. The one problem you run into with this is that if the user just closes the browser window rather than using your nice logout function, the session lingers until the timeout period elapses. I didn't like that! My app is frames-based, and I already had one hidden frame, so I added the following to the body tag of that frame's source document: onUnload=openLogoffPopup
RE: list active sessions.
I spent a couple of days last week implementing just such a thing, so I feel qualified to answer :) There is no easy way to do it. There USED to be a SessionContext object available in the servlet spec that would allow you to do a lot of cool things with sessions, but it was removed as of spec 2.1 I think because Sun believed it to be a security risk. Unfortunately there was nothing added to take it's place. The way you have to do this, or at least one way (the only way I found) is to track it yourself. First, I already had an AppConfig object that contains a static HashMap. This has a bunch of config values for my app loaded from a config file at startup. I then added an activeSessions HashMap to that class. Create a similar class for yourself, along the lines of the following: import java.util.HashMap; public class AppConfig { private static HashMap activeUsers = null; public static HashMap activeUsers() { return activeUsers; } public static void setActiveUsers(HashMap inActiveUsers) { activeUsers = inActiveUsers; } } Then, create a SessionListener something like the following: package com.mycompany.myapp; import java.util.HashMap; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionListener; public class SessionListener implements HttpSessionListener { public void sessionCreated(HttpSessionEvent se) { HashMap activeUsers = (HashMap)AppConfig.getActiveUsers(); synchronized (activeUsers) { activeUsers.put(se.getSession().getId(), new HashMap()); } } public void sessionDestroyed(HttpSessionEvent se) { HashMap activeUsers = (HashMap)AppConfig.getActiveUsers(); synchronized (appConfig) { activeUsers.remove(se.getSession().getId()); } } } Then just add the following to web.xml after your servlet section: listener listener-classcom.mycompany.myapp.SessionListener/listener-class /listener Basically, every time a session is created, you'll get an entry in the activeUsers HashMap keyed by sessionID, and the record will be removed when the session is destroyed. Further, what I do is that when my logon Action is called, when the user is validated I add some information for that user into the HashMap (first name, last name, logon time, etc). This allows me to have a pretty nice little tracking display in my app. The one problem you run into with this is that if the user just closes the browser window rather than using your nice logout function, the session lingers until the timeout period elapses. I didn't like that! My app is frames-based, and I already had one hidden frame, so I added the following to the body tag of that frame's source document: onUnload=openLogoffPopup(); ... and then the openLogoffPopup() function: function openLogoffPopup() { windowHandle = window.open(, , width=200,height=1,top=1,left=1); str = + html + head + title + /title + /head; str += + body onLoad=\window.location='%=request.getContextPath() + /app/logoff.app%';\; str += + table width=\100%\ height=\100%\ border=\0\; str += + tr + td align=\center\ valign=\middle\; str += + span style=\color:#00;font-family:arial;font-size:11pt;font-weight:bold;\; str += Logging out of application... + /span; str += + /td + /tr; str += + /table; str += + /body + /html; windowHandle.document.write(str); windowHandle.document.close(); } That calls the logoff Action whcih does not much more than session.invalidate(). This works well in IE, I do not know if it is cross-browser though (not a concern for my company). It should work fine to add this to all your JSP's, assuming your app isn't frame-based, I think it'll work just the same. But, maybe you can live with the session lingering if the window is closed anyway. It's probably not a big concern if the timeout period is short enough, but you need to recognize that you may see more than one session per user for a few minutes if they log on again. Hope that helps! Frank From: Alex [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: list active sessions. Date: Mon, 21 Jun 2004 08:52:42 -0400 (EDT) Is there a way to list all sessions which are currently active for the webapp which would be calling for such a list? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Is your PC infected? Get a FREE online computer virus scan from McAfee® Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: list active sessions.
Well, never having tried it, I don't know for sure :) But, since we're only talking about a pretty small static object in memory, I assume that would be better-performing than writing out to a database (although obviously you have no persistence, but I don't think that's a problem when talking about sessions). And although there is a critical section involved, since it's only during logon and not every request, I don't imagine it's a significant problem. If your just recording the session ID and not the extra info I do later on, I suspect it would scale just fine. The one problem I can see is if your talking about a distributed environment. Maybe in that case writing out to a database is a better idea. Certainly it's trivial to do that from the listener. You avoid the critical section then, so maybe the trade-off between that and the extra hit of the database access makes it a wash. If you kept it in-memory, it might even be OK because the AppConfig class should be serializable, so theoretically it should be able to get replicated, but I certainly wouldn't go that route, I'd write it to a database and not deal with any potential synchronization issues at all. That means you probably want to write a Struts plug-in, or something else to run at startup, to clear out the database, but that's also not a big deal. So, while I don't know for sure that it will scale to 250 users, I can't see any real problem with it doing so, certainly if it's a single server I'd see it's probably fine as-is, a cluster might require going to a database instead. Frank From: Alex [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: RE: list active sessions. Date: Mon, 21 Jun 2004 09:31:33 -0400 (EDT) How would your application cope if it were required to scale up to 250 concurrent users ? It's an interesting approach. Currently I record limited information to a db. All I really want is to be able to list all the active session id's...nothing more. If it's being done already, why do it again... On Mon, 21 Jun 2004, Frank Zammetti wrote: Date: Mon, 21 Jun 2004 09:45:05 -0400 From: Frank Zammetti [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: RE: list active sessions. I spent a couple of days last week implementing just such a thing, so I feel qualified to answer :) There is no easy way to do it. There USED to be a SessionContext object available in the servlet spec that would allow you to do a lot of cool things with sessions, but it was removed as of spec 2.1 I think because Sun believed it to be a security risk. Unfortunately there was nothing added to take it's place. The way you have to do this, or at least one way (the only way I found) is to track it yourself. First, I already had an AppConfig object that contains a static HashMap. This has a bunch of config values for my app loaded from a config file at startup. I then added an activeSessions HashMap to that class. Create a similar class for yourself, along the lines of the following: import java.util.HashMap; public class AppConfig { private static HashMap activeUsers = null; public static HashMap activeUsers() { return activeUsers; } public static void setActiveUsers(HashMap inActiveUsers) { activeUsers = inActiveUsers; } } Then, create a SessionListener something like the following: package com.mycompany.myapp; import java.util.HashMap; import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionListener; public class SessionListener implements HttpSessionListener { public void sessionCreated(HttpSessionEvent se) { HashMap activeUsers = (HashMap)AppConfig.getActiveUsers(); synchronized (activeUsers) { activeUsers.put(se.getSession().getId(), new HashMap()); } } public void sessionDestroyed(HttpSessionEvent se) { HashMap activeUsers = (HashMap)AppConfig.getActiveUsers(); synchronized (appConfig) { activeUsers.remove(se.getSession().getId()); } } } Then just add the following to web.xml after your servlet section: listener listener-classcom.mycompany.myapp.SessionListener/listener-class /listener Basically, every time a session is created, you'll get an entry in the activeUsers HashMap keyed by sessionID, and the record will be removed when the session is destroyed. Further, what I do is that when my logon Action is called, when the user is validated I add some information for that user into the HashMap (first name, last name, logon time, etc). This allows me to have a pretty nice little tracking display in my app. The one problem you run into with this is that if the user just closes the browser window rather than using your nice logout function, the session lingers until the timeout period elapses. I didn't like
RE: Design question ..
Probably the easiest way to handle this is simply to have a constraint on your database that says a record cannot be added if some field is 0 (or a unique constraint, depending on how your table is keyed). Then, just catch the exception in your code and check to see if it's a violation of your rule, then return a message to the user saying the class has filled up. Simply put, don't worry about them putting the class in the shopping cart. Make sure you have a note on the site that says they are NOT actually registered until the shopping cart is processed. Then, let the database handle the concurrency issues (which they are very good at!) and you don't have to complicate your code any. I generally like staying away from database-level rules like this, just in case you tie yourself to a particular vendor, but something like this is pretty safe, and is tailor-made for such a mechanism. Frank From: Mufaddal Khumri [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Design question .. Date: Mon, 21 Jun 2004 12:37:04 -0700 Hi, I am in the process of writing a webapp that allows users to make a payment and register for a course. Using Apache -- Tomcat --- MySQL. The question is a design question i guess, unless there is something in Tomcat that I can leverage, which i might not know. I know that this is a design question , but since I am using Tomcat as my JSP/Servlet container and since the participants here are experts in this field , I thought that I might get some good pointers here. Lets take this scenario: User 1 and User 2 are trying to register for a course called Taekwando. The fee for registering is X amount. Also there is another course called Majagutamba and it costs Y amount. Both theses courses have exactly 1 seat remaining. Now lets say user 1 adds both these courses in his shopping cart, and user 2 does the same, since user 1 has not completed his transaction and paid the enrollment table wont have an entry for user1. (The Enrollment table keeps track of which user is enrolled in which course). Therefore both users have both those courses in their shopping carts. Now both of them proceed to checkout. They enter their credit card information and say submit. Both those users make payments and get enrolled for both those courses!!! Which is wrong , since both those courses could only enroll 1 more person, instead two new users were just added. To avoid the above problem one could implement a singleton synchronized Transaction object that would process shopping cart checkout in a queue. The problem with this approach are: 1. If anything goes wrong with any one transaction, it would hold up the entire queue. (Well we can have some sort of timeouts and take care of that.) 2. Since this is a syncrhonized singleton and if the traffic for registering for the courses is high, this would be a slow process for which the user will have to wait. Is there a better solution, algorithm, to do this ? Any help is appreciated. Thanks, - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ MSN Movies - Trailers, showtimes, DVD's, and the latest news from Hollywood! http://movies.msn.click-url.com/go/onm00200509ave/direct/01/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Design question ..
If your thinking in terms of singletons and synchronized blocks, it seems like you are thinking along the lines of doing this all in-memory. You CAN do that, but it's generally not a good idea. First, I don't know if your dealing with a clustered environment, but if you are you'll find that you have synchronization issues to deal with. Second, the obvious: if power goes out, everything is lost. If your dealing with a database, there's at least the possibility of recovering things. Third, any time you introduce a synchronized block in a J2EE-based application you have to ask yourself if your design isn't flawed because you are supposed to let the container handle all threading issues and your code should always be thread-safe. I myself have broken this rule on occassion, and I believe it to be valid to do sometimes, but you need to be sure it's truly the right anwer. Assuming you decide it is, realize that any synchronized block of code means your introducing a bottleneck to the application. You may decide it's insignificant, but you are essentially serializing all requests that go through that critical section, so you need to really make sure it's the right thing to do. In a recent app, I had a critical section during logon. This is very different than something that's a transaction within the app that might happen a number of times for a given user since the logon shouldn't be happening very often and you probably won't get too many users doing it concurrently, so it's not a big issue as compared to something that might be happening a lot for many different users. This really strikes me as something that should be done in a database, whether your letting the database handle the concurrance issues or you do so in your code yourself, but either way, that's really the way I'd be looking. Frank From: Mufaddal Khumri [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Re: Design question .. Date: Mon, 21 Jun 2004 14:34:51 -0700 Hi, Yes , first come first is something that I prefer too. But I will need a singleton java object with a synchronized method to do the transaction. The transaction would involve 1. Check data 2. Register 3. commit data to database. After the method completes i can send them a confirmation. The downside to this approach is that if lots of users are registering for courses online , they might experience a delay. On Jun 21, 2004, at 12:47 PM, Peter Lin wrote: There's a couple of different ways to handle this. 1. do not do it in real time. this is the easiest solution, but it means a human has to be the one who figures who gets what class. 2. use JMS to update each user's session and make it so that once the class has no more entries, no one else can add it to their cart. Say user 1 submits before user 2. if user 1 registers before 2, a message is sent to the java bean in memory to update the cart 3. process the orders on a first come first serve basis, but do not gaurantee the person is signed up for it. In the response email state, you will get a confirmation of successful regisration. This is usually the easiest way to assuming you send confirmation in reasonable amount of time. This implies the transaction are processed async with some kind of queue 4. check availability before starting the transaction. this means some kind of locking at the row level. I'm sure there are other ways of doing it. Personally, I prefer handling the transaction on a first come first serve basis and send out confirmation in reasonable time. peter On Mon, 21 Jun 2004 12:37:04 -0700, Mufaddal Khumri [EMAIL PROTECTED] wrote: Hi, I am in the process of writing a webapp that allows users to make a payment and register for a course. Using Apache -- Tomcat --- MySQL. The question is a design question i guess, unless there is something in Tomcat that I can leverage, which i might not know. I know that this is a design question , but since I am using Tomcat as my JSP/Servlet container and since the participants here are experts in this field , I thought that I might get some good pointers here. Lets take this scenario: User 1 and User 2 are trying to register for a course called Taekwando. The fee for registering is X amount. Also there is another course called Majagutamba and it costs Y amount. Both theses courses have exactly 1 seat remaining. Now lets say user 1 adds both these courses in his shopping cart, and user 2 does the same, since user 1 has not completed his transaction and paid the enrollment table wont have an entry for user1. (The Enrollment table keeps track of which user is enrolled in which course). Therefore both users have both those courses in their shopping carts. Now both of them proceed to checkout. They enter their credit card information and say submit. Both those users make payments and get enrolled for both those courses!!! Which is wrong , since both those courses could only enroll 1
Re: Design question ..
The more typical way of doing this is to use JDBC transactional code. In essence, the concurrancy issues are handled under the covers by the classes, JDBC driver and database. You just start a transaction, do your updates, and commit the transaction. Catch any failures that occur and deal with them. Assuming you have proper constraints on the database, those are the exceptions you'll be looking for. Frank From: Mufaddal Khumri [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Re: Design question .. Date: Mon, 21 Jun 2004 14:41:12 -0700 I understand this method of doing it and I understand the pseudo code too. I believe this code will be in a synchronized method that should be placed in a singleton object. The code validates information. One example validation could be getting current registrations for the course and seeing if there is place left for this new user to enroll in that course. If this method is not synchronized then two different users could be in this same function validating their data and then they would try to register for the course too. If the number of users using the system to register for courses is high this singleton object encapsulating this synchronized method, would e a bottle neck. Is there any other solution or is this standard implementation? On Jun 21, 2004, at 12:54 PM, Jérôme Duval wrote: Most commercial databases implement a solution to this problem since it is fairly common. For MySQL, you must use the InnoDB engine (at least for now). You use the concept of transaction. To do this, you must turn the AutoCommit mode to off (some client have this mode off by default, some do not. Check your documentation. If you are going through JDBC Connections are always in AutoCommit(true)!). You must also set the Transaction Mode to Transaction_Serializable which locks table so that no one else then you can read the data in your tables. The code looks something like this: try { //Validate information //Add the record in the table //Bill the customer //commit transaction } catch (SQLException) { //rollback the transaction cause something went wrong } finally { //close the connection } Where you bill the customer is dicussable (it is related to the transaction but does not require DB access). It's all up to you really. A couple of things to notice: - TRANSACTION_SERIALIZABLE is the most demanding mode for your database server. - If you forget even one commit() or rollback() you might lose data to locking. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Mufaddal Khumri Software Developer Waves In Motion Phone: 602 956 7080 x 26 Email: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Get fast, reliable Internet access with MSN 9 Dial-up now 3 months FREE! http://join.msn.click-url.com/go/onm00200361ave/direct/01/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Design question ..
The first point is a very good one, I wouldn't have thought of it! The second point is certainly arguable. I see where your coming from, but if it's a business rule, it by definition belongs in the model layer. Remember, view is easy, the controller interfaces the two, and business logic of an application is the model layer. That aside, I really do like your idea about kind of putting a hold on the class. I think that's a very good suggestion and a good model to follow. but in the end Justin, you would do well, I think, to do this in the database, i.e., have a locked field as write to it. The complication there is you'll need some method to unlock abandoned items periodically. Frank From: Justin Ruthenbeck [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Re: Design question .. Date: Mon, 21 Jun 2004 14:45:05 -0700 Since everyone else seems to have an opinion on this, I figure that I might as well share mine. :) A couple things to keep in mind: (*) Depending on your geographic location, you may have a legal responsibility to make sure that an item listed as available is, indeed, available. In other words, you can't tell a user that an item is available, let them put into their cart, then tell them it's not available when they try to pay for it. This is municipality-specific, but something to keep in mind for those doing cross-border sales. (*) The requirement you have described is a business-process requirement. It is not technical and therefore, IMHO, should not be satisfied with row locking, transaction manipulation, etc. Satisfy it on the controller level and avoid polluting your model with stuff like this. My personal inclination (which could change depending on the situation) would be to give users an X minute (logical) lock once something has been put in their cart. If they don't buy it (or indicate they want to keep it) after that time is up, it goes back on the shelf. In other words, treat everything in your inventory like a real object ... if a consumer wants to buy it, give them a pickup-ticket that they can take to the cashier. Ensure that the number of pickup-tickets equals the number of real items in inventory. The primary benefit here is that you'll fail fast instead of promising something that you can't deliver. (This isn't my idea, BTW ... take a look at TicketMaster when a hot concert goes on sale to see this in action) justin At 12:37 PM 6/21/2004, you wrote: Hi, I am in the process of writing a webapp that allows users to make a payment and register for a course. Using Apache -- Tomcat --- MySQL. The question is a design question i guess, unless there is something in Tomcat that I can leverage, which i might not know. I know that this is a design question , but since I am using Tomcat as my JSP/Servlet container and since the participants here are experts in this field , I thought that I might get some good pointers here. Lets take this scenario: User 1 and User 2 are trying to register for a course called Taekwando. The fee for registering is X amount. Also there is another course called Majagutamba and it costs Y amount. Both theses courses have exactly 1 seat remaining. Now lets say user 1 adds both these courses in his shopping cart, and user 2 does the same, since user 1 has not completed his transaction and paid the enrollment table wont have an entry for user1. (The Enrollment table keeps track of which user is enrolled in which course). Therefore both users have both those courses in their shopping carts. Now both of them proceed to checkout. They enter their credit card information and say submit. Both those users make payments and get enrolled for both those courses!!! Which is wrong , since both those courses could only enroll 1 more person, instead two new users were just added. To avoid the above problem one could implement a singleton synchronized Transaction object that would process shopping cart checkout in a queue. The problem with this approach are: 1. If anything goes wrong with any one transaction, it would hold up the entire queue. (Well we can have some sort of timeouts and take care of that.) 2. Since this is a syncrhonized singleton and if the traffic for registering for the courses is high, this would be a slow process for which the user will have to wait. Is there a better solution, algorithm, to do this ? Any help is appreciated. Thanks, - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Justin Ruthenbeck Software Engineer, NextEngine Inc. justinr - AT - nextengine DOT com Confidential. See: http://www.nextengine.com/confidentiality.php __ - To
Re: Design question ..
I'd need to know what RDBMS you were using to give you an example, and then I'd have to go look up in some references to see how to write the rule. But from a generic standpoint... I would add a number_registered field to your course table. Each time someone tried to enroll in a class, you do a check like if (course.maxregistation == -1 || (course.number_registered course.maxregistration)) { allow the update } else { disallow update } That's not literally the code, but that's the logic of it. It might be a constraint, it might be a trigger, I'm not sure which will do it for you (although triggers generally result in updates to other tables, so I'm thinking constraint). That way, if the rule disallows the update, you'll get an exception in your code with an error code or message you can check for specifically and inform the user. Frank From: Mufaddal Khumri [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Re: Design question .. Date: Mon, 21 Jun 2004 14:47:52 -0700 Hi Frank I understand this approach. The problem is that the course table has a field called maxregistration if this field is set to -1 it means that there is no limit. If there is a value in this field, it will be = 1. I have another table called Enrollments. This table has courseId, userId information. It keeps track of what user is enrolled in what course. I have a waitinglist table which has userId, courseId, timestamp. It keeps track of what users are waiting to be enrolled in a course that has met its capacity. The instructor can give override to users in waitinglist for a table. An override transfers a user from the WaitingList table to the Enrollment table. This means that at any given time the enrollment table could have more than course.maxregistration users enrolled for a course. Could you give me an example of a constraint that I could put on my tables so that it does not allow registrations more than course.maxregistration? On Jun 21, 2004, at 12:56 PM, Frank Zammetti wrote: Probably the easiest way to handle this is simply to have a constraint on your database that says a record cannot be added if some field is 0 (or a unique constraint, depending on how your table is keyed). Then, just catch the exception in your code and check to see if it's a violation of your rule, then return a message to the user saying the class has filled up. Simply put, don't worry about them putting the class in the shopping cart. Make sure you have a note on the site that says they are NOT actually registered until the shopping cart is processed. Then, let the database handle the concurrency issues (which they are very good at!) and you don't have to complicate your code any. I generally like staying away from database-level rules like this, just in case you tie yourself to a particular vendor, but something like this is pretty safe, and is tailor-made for such a mechanism. Frank From: Mufaddal Khumri [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Design question .. Date: Mon, 21 Jun 2004 12:37:04 -0700 Hi, I am in the process of writing a webapp that allows users to make a payment and register for a course. Using Apache -- Tomcat --- MySQL. The question is a design question i guess, unless there is something in Tomcat that I can leverage, which i might not know. I know that this is a design question , but since I am using Tomcat as my JSP/Servlet container and since the participants here are experts in this field , I thought that I might get some good pointers here. Lets take this scenario: User 1 and User 2 are trying to register for a course called Taekwando. The fee for registering is X amount. Also there is another course called Majagutamba and it costs Y amount. Both theses courses have exactly 1 seat remaining. Now lets say user 1 adds both these courses in his shopping cart, and user 2 does the same, since user 1 has not completed his transaction and paid the enrollment table wont have an entry for user1. (The Enrollment table keeps track of which user is enrolled in which course). Therefore both users have both those courses in their shopping carts. Now both of them proceed to checkout. They enter their credit card information and say submit. Both those users make payments and get enrolled for both those courses!!! Which is wrong , since both those courses could only enroll 1 more person, instead two new users were just added. To avoid the above problem one could implement a singleton synchronized Transaction object that would process shopping cart checkout in a queue. The problem with this approach are: 1. If anything goes wrong with any one transaction, it would hold up the entire queue. (Well we can have some sort of timeouts and take care of that.) 2. Since this is a syncrhonized singleton and if the traffic for registering for the courses
RE: How can I inhibit web navegation?
Well, you can stop directory lists by setting listings to false in web.xml in /tomcat/conf (the global web.xml file). There are comments about it in the file. As for the navigation thing, you can externalize your security with something like Netegrity Siteminder. This will allow you to stop users from accessing any page of your application except those you define as unprotected, unless they have a valid session established. However, you can do much the same thing within your application, and I think this is what's generally done. On each request, see if a valid session exists. If not, redirect to some logon page, or whatever is appropriate. That takes care of PART of the problem. The other part is once a session IS established, there's not really anything to stop a user from going to any URL they can properly construct. One way to handle that is that on each request, you set in session what page was being viewed. Then, you check that whatever page was last being viewed is a valid predecessor to the page being requested. In other words, if the user is on page A, then you might know that in your application flow it's only ever valid to go to Page B, never directly to page C. So, when page A is requested, yiou set in session a flag to say page A was last being viewed. Now, when page B or C is requested, you check that value. If page B is requested and the value is A, then you know you are OK. If it's anything else, redirect the request. Hope that helps! Frank From: Bachler, Elisabeth (Elisabeth) [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Subject: How can I inhibit web navegation? Date: Thu, 17 Jun 2004 15:35:14 +0200 Hello, I have a web application that runs under jakarta-tomcat-5.0.19. The root of my application is: /opt/jakarta-tomcat-5.0.19/webapps/provision/ I can access the application through: http://135.88.100.251:8080/provision/web/login.jsp Now, I don't want the user to be able to navigate through my application. For instance, if he enters: http://135.88.100.251:8080/provision/web/ I don't want him to see the directories (or even the files) in it. I think they must be a Context parameter that can do it but I don't know how. Could you help? Thanks Elisabeth - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Stop worrying about overloading your inbox - get MSN Hotmail Extra Storage! http://join.msn.click-url.com/go/onm00200362ave/direct/01/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Vexing session creation issue
I sent this to the Struts mailing list as well, but it seems like it could be a Tomcat issue as well (probably just some config option I don't know about)... Argh, this one is hurting my head... I have an application that starts out by returning index.jsp (it's the welcome file). This JSP opens a new window via JavaScript and loads into it index1.jsp. index1.jsp populates five frames of a frameset. At the end of all this, my logon screen is seen. The important thing to note here is that no Actions are executed to this point, it's just loading JSP's, and there is not really any JSP code in any of these except for a bunch of request.getContextPath() calls. No code accesses session or anything like that, and there are only two references to getting anything out of request (because the logon page might be shown after a bad attempt, and I need to get the userID and password that was attempted). In all of them, I have session=false in the page tag. Now... I've created a SessionListener to tell me when a session is created or destroyed. Problem is, during all these JSP loads, the create event fires TWICE! What's worse, session is NOT null (which I expected it to be), and worse still, I'm getting two DIFFERENT session ID's! It looks like two sessions are being created when it seems like absolutely NONE should be. I'm banging my head against the wall with this one. Anyone have any ideas? Thanks folks! Frank _ MSN 9 Dial-up Internet Access fights spam and pop-ups now 3 months FREE! http://join.msn.click-url.com/go/onm00200361ave/direct/01/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Vexing session creation issue
Never mind... as usual, it was a stupid developer trick... Turns out I forgot two JSP's that get loaded, and they didn't have session=false in them, so that explains it. My bad. Frank From: Frank Zammetti [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Vexing session creation issue Date: Wed, 16 Jun 2004 10:35:43 -0400 I sent this to the Struts mailing list as well, but it seems like it could be a Tomcat issue as well (probably just some config option I don't know about)... Argh, this one is hurting my head... I have an application that starts out by returning index.jsp (it's the welcome file). This JSP opens a new window via JavaScript and loads into it index1.jsp. index1.jsp populates five frames of a frameset. At the end of all this, my logon screen is seen. The important thing to note here is that no Actions are executed to this point, it's just loading JSP's, and there is not really any JSP code in any of these except for a bunch of request.getContextPath() calls. No code accesses session or anything like that, and there are only two references to getting anything out of request (because the logon page might be shown after a bad attempt, and I need to get the userID and password that was attempted). In all of them, I have session=false in the page tag. Now... I've created a SessionListener to tell me when a session is created or destroyed. Problem is, during all these JSP loads, the create event fires TWICE! What's worse, session is NOT null (which I expected it to be), and worse still, I'm getting two DIFFERENT session ID's! It looks like two sessions are being created when it seems like absolutely NONE should be. I'm banging my head against the wall with this one. Anyone have any ideas? Thanks folks! Frank _ MSN 9 Dial-up Internet Access fights spam and pop-ups now 3 months FREE! http://join.msn.click-url.com/go/onm00200361ave/direct/01/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ MSN Toolbar provides one-click access to Hotmail from any Web page FREE download! http://toolbar.msn.click-url.com/go/onm00200413ave/direct/01/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Vexing session creation issue
This is what my research is indicating too, but there seems to be quite a bit of confusion over this point, and not just from me, I've seen a number of posts along these lines... If I call request.getSession(false), the javadocs says of the getSession() method: Returns the current HttpSession associated with this request or, if if there is no current session and create is true, returns a new session. If create is false and the request has no valid HttpSession, this method returns null. But this is not the behavior I'm seeing in my Logon Action... I am in fact NOT getting null back, I am getting a valid session (which no attributesn though). This is in line with what you said, but it seems the javadocs is wrong, and this means that you can never reliably check if a session is null by simply doing session==null, you instead must check if some attribute is present or not to indicate if it's a live session (which is what I was doing previously, I was trying to not do it because it seemed inelegant) because it seems that when a session is invalidated or times out or of course is newly created, the attribute won't be present. Am I missing something, or is the javadocs in fact incorrect here? Frank From: Shapira, Yoav [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: RE: Vexing session creation issue Date: Wed, 16 Jun 2004 10:47:07 -0400 Hi, The behavior you're seeing is consistent with the servlet specification. If a client chooses not to join a session (which the page session=false directive indicates), the container may still create sessions for the client, just that it will be a new session each time, with a new ID and empty attributes. This is in the Servlet Spec but summarized nicely in the 2nd to last paragraph of the HttpSession class JavaDoc. Yoav Shapira Millennium Research Informatics -Original Message- From: Frank Zammetti [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 16, 2004 10:36 AM To: [EMAIL PROTECTED] Subject: Vexing session creation issue I sent this to the Struts mailing list as well, but it seems like it could be a Tomcat issue as well (probably just some config option I don't know about)... Argh, this one is hurting my head... I have an application that starts out by returning index.jsp (it's the welcome file). This JSP opens a new window via JavaScript and loads into it index1.jsp. index1.jsp populates five frames of a frameset. At the end of all this, my logon screen is seen. The important thing to note here is that no Actions are executed to this point, it's just loading JSP's, and there is not really any JSP code in any of these except for a bunch of request.getContextPath() calls. No code accesses session or anything like that, and there are only two references to getting anything out of request (because the logon page might be shown after a bad attempt, and I need to get the userID and password that was attempted). In all of them, I have session=false in the page tag. Now... I've created a SessionListener to tell me when a session is created or destroyed. Problem is, during all these JSP loads, the create event fires TWICE! What's worse, session is NOT null (which I expected it to be), and worse still, I'm getting two DIFFERENT session ID's! It looks like two sessions are being created when it seems like absolutely NONE should be. I'm banging my head against the wall with this one. Anyone have any ideas? Thanks folks! Frank _ MSN 9 Dial-up Internet Access fights spam and pop-ups - now 3 months FREE! http://join.msn.click-url.com/go/onm00200361ave/direct/01/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Watch the online reality show Mixed Messages with a friend and enter to win a trip to NY http://www.msnmessenger-download.click-url.com/go/onm00200497ave/direct/01/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Vexing session ceration issue
isNew() didn't seem to give me the answer I was expecting at various points in the code. I'm sure it's just me not looking at something right, but I went with the attribute in session (which is really diong the same thing you said, which is asking session the question!). This also seems to be the common approach, based on my Googling. I just wish I knew that BEFORE I removed that same code! :) I'm all set now though, things are working nicely. Frank From: Jérôme Duval [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: RE: Vexing session ceration issue Date: Wed, 16 Jun 2004 14:02:18 -0400 I think you are asking the wrong object for info. You want to know if the session exists or not, so ask the session! I would use the isNew() method, rather then getSession(false), simply because the session is the best placed object to know if it exists or not. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Looking to buy a house? Get informed with the Home Buying Guide from MSN House Home. http://coldwellbanker.msn.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How can I access a file located in WEB-INF
Further, you will probably want to be able to construct the path to /WEB-INF at runtime rather than hardcoding paths... You can do that as follows: String fullPath = getServletContext().getRealPath(path); where path is a context-relative path (can include a filename if you want). For instance, I use this in a Struts plug-in to initialize a custom connection pool. The value I use for path is /WEB-INF/ConnPoolConfig.xml. The above gives you the full system path to the file (in my case, C:\tomcat\webapps\toa\WEB-INF on my development machine), so you can easily open it then. If you just use the above to get the path to a path (i.e., you want the fully-qualified path to WEB-INF in the current webapp, but not a specific file), you will need to append a file separator character at the end before appending a filename. Frank From: Tom K [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Subject: RE: How can I access a file located in WEB-INF Date: Wed, 16 Jun 2004 13:52:42 -0500 File dir = new File(directoryName); String[] children = dir.list(); if (children == null) { // Either dir does not exist or is not a directory } else { for (int i=0; ichildren.length; i++) { // Get filename of file or directory String filename = children[i]; } } Tom Kochanowicz -Original Message- From: STOCKHOLM, Raymond [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 16, 2004 2:15 AM To: Tomcat Users List Subject: How can I access a file located in WEB-INF Hi, I need to access a file located in the directory WEB-INF of my web application. In fact, in WEB-INF/conf. How can I open this file in one of my servlet ? Any advise is welcome. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.682 / Virus Database: 444 - Release Date: 5/11/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.682 / Virus Database: 444 - Release Date: 5/11/2004 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ MSN 9 Dial-up Internet Access fights spam and pop-ups now 3 months FREE! http://join.msn.click-url.com/go/onm00200361ave/direct/01/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How can I access a file located in WEB-INF
I didn't know that, thanks for the heads-up! From: Shapira, Yoav [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: RE: How can I access a file located in WEB-INF Date: Wed, 16 Jun 2004 15:14:33 -0400 Hi, Just remember getRealPath returns null in a packed WAR file. Better approaches are in the tomcat FAQ. Yoav Shapira Millennium Research Informatics -Original Message- From: Frank Zammetti [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 16, 2004 3:14 PM To: [EMAIL PROTECTED] Subject: RE: How can I access a file located in WEB-INF Further, you will probably want to be able to construct the path to /WEB- INF at runtime rather than hardcoding paths... You can do that as follows: String fullPath = getServletContext().getRealPath(path); where path is a context-relative path (can include a filename if you want). For instance, I use this in a Struts plug-in to initialize a custom connection pool. The value I use for path is /WEB- INF/ConnPoolConfig.xml. The above gives you the full system path to the file (in my case, C:\tomcat\webapps\toa\WEB-INF on my development machine), so you can easily open it then. If you just use the above to get the path to a path (i.e., you want the fully-qualified path to WEB-INF in the current webapp, but not a specific file), you will need to append a file separator character at the end before appending a filename. Frank From: Tom K [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Subject: RE: How can I access a file located in WEB-INF Date: Wed, 16 Jun 2004 13:52:42 -0500 File dir = new File(directoryName); String[] children = dir.list(); if (children == null) { // Either dir does not exist or is not a directory } else { for (int i=0; ichildren.length; i++) { // Get filename of file or directory String filename = children[i]; } } Tom Kochanowicz -Original Message- From: STOCKHOLM, Raymond [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 16, 2004 2:15 AM To: Tomcat Users List Subject: How can I access a file located in WEB-INF Hi, I need to access a file located in the directory WEB-INF of my web application. In fact, in WEB-INF/conf. How can I open this file in one of my servlet ? Any advise is welcome. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.682 / Virus Database: 444 - Release Date: 5/11/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.682 / Virus Database: 444 - Release Date: 5/11/2004 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ MSN 9 Dial-up Internet Access fights spam and pop-ups - now 3 months FREE! http://join.msn.click-url.com/go/onm00200361ave/direct/01/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Looking to buy a house? Get informed with the Home Buying Guide from MSN House Home. http://coldwellbanker.msn.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Custom resource loader
May I suggest one wacky idea? I'm not saying this is GOOD or anything, but it's probably a bit outside the box, for whatever that's worth... What if you had all your common JSPs in a given directory, like so (let's talk Tomcat for a minute, but it doesn't matter)... /tomcat/webapps/commonjsps /tomcat/webapps/webapp1 /tomcat/webapps/webapp2 Then, in either webapp1 or webapp2, let's say you want to use the JSP myJSP1.jsp in the common jsps directory... What if you had a JSP in webapp1 and webapp2 that was just this: %@ page language=java % %@ include file=../commonjsps/myJSP1.jsp.inc % My syntax might be a little off, but I think the concept is clean. You would have to have basically a dummy page that includes the real page, and that could be a pain, but I think this would work, and maybe it's quicker to do than a custom resource loader. Just a thought. Frank From: Keene, David [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Custom resource loader Date: Thu, 10 Jun 2004 10:43:18 -0700 Greetings, A while ago on this list I saw some discussion about custom resource loaders (extending FileDirContext) to load resources from multiple root paths. I am looking specifically to do this in order to grab jsp pages from a 'commons' directory that many of my sites (which run in different contexts) use. Was there any consensus to the right way to do this? Has anyone done this already and would be willing to share? My plan is to send an extra attribute to the Resource tag in the server.xml, which is a comma delimited list of additional paths in the order they should be searched for a given file. The ExtendedDirContext would then keep all the paths on a list and iterate through them until a named resource was located. Any thoughts, Dave Keene - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Looking to buy a house? Get informed with the Home Buying Guide from MSN House Home. http://coldwellbanker.msn.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Custom resource loader
Well, here's maybe a better solution (sort of)... It hinges on the answer to a question I don't know the answer to off the top of my head, that is, if I do an include of something mapped to an Action, will the Action be executed? What I'm thinking is, what if your include results in an Action execution, and that Action reads in the file you want to include and outputs it to the Response object manually? Then you could access files anywhere on your file system. I think I may be getting too crazy here :) Frank From: Keene, David [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: RE: Custom resource loader Date: Thu, 10 Jun 2004 11:59:10 -0700 That's a good ide frank, but it may not work. FilrDirContext has a normalize method... the javadoc comment says: * Return a context-relative path, beginning with a /, that represents * the canonical version of the specified path after .. and . elements * are resolved out. If the specified path attempts to go outside the * boundaries of the current context (i.e. too many .. path elements * are present), return codenull/code instead. Doh! Also, it would be nice to have the freedom to place the 'common' elsewhere on the system. Dave -Original Message- From: Frank Zammetti [mailto:[EMAIL PROTECTED] Sent: Thursday, June 10, 2004 11:17 AM To: [EMAIL PROTECTED] Subject: RE: Custom resource loader May I suggest one wacky idea? I'm not saying this is GOOD or anything, but it's probably a bit outside the box, for whatever that's worth... What if you had all your common JSPs in a given directory, like so (let's talk Tomcat for a minute, but it doesn't matter)... /tomcat/webapps/commonjsps /tomcat/webapps/webapp1 /tomcat/webapps/webapp2 Then, in either webapp1 or webapp2, let's say you want to use the JSP myJSP1.jsp in the common jsps directory... What if you had a JSP in webapp1 and webapp2 that was just this: %@ page language=java % %@ include file=../commonjsps/myJSP1.jsp.inc % My syntax might be a little off, but I think the concept is clean. You would have to have basically a dummy page that includes the real page, and that could be a pain, but I think this would work, and maybe it's quicker to do than a custom resource loader. Just a thought. Frank From: Keene, David [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Custom resource loader Date: Thu, 10 Jun 2004 10:43:18 -0700 Greetings, A while ago on this list I saw some discussion about custom resource loaders (extending FileDirContext) to load resources from multiple root paths. I am looking specifically to do this in order to grab jsp pages from a 'commons' directory that many of my sites (which run in different contexts) use. Was there any consensus to the right way to do this? Has anyone done this already and would be willing to share? My plan is to send an extra attribute to the Resource tag in the server.xml, which is a comma delimited list of additional paths in the order they should be searched for a given file. The ExtendedDirContext would then keep all the paths on a list and iterate through them until a named resource was located. Any thoughts, Dave Keene - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Looking to buy a house? Get informed with the Home Buying Guide from MSN House Home. http://coldwellbanker.msn.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ MSN Toolbar provides one-click access to Hotmail from any Web page FREE download! http://toolbar.msn.click-url.com/go/onm00200413ave/direct/01/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Custom resource loader
I agree, and notice I never said it was a GOOD idea :) Let me know what you find, I'd be interested to know what you turn up. Frank From: Keene, David [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: RE: Custom resource loader Date: Thu, 10 Jun 2004 15:05:25 -0700 I don't know if that would work, but even if it did, I think the custom loader is a better solution. I'm porting hundreds of legacy pages over from a system that used have its common directory in the same context (it really does need to move though). The most intuitive way to include another jsp is through @include, and I'd rather not jump through hoops to use another way of including them (which I believe that using an Action would entail). I'm sure someone already solved this problem. He was talking it up about a year ago ... (checking archives)... David Keys said he made one in 2003-02-05. (google is great). Does anyone have the code for this that they'd like to share? Dave -Original Message- From: Frank Zammetti [mailto:[EMAIL PROTECTED] Sent: Thursday, June 10, 2004 2:37 PM To: [EMAIL PROTECTED] Subject: RE: Custom resource loader Well, here's maybe a better solution (sort of)... It hinges on the answer to a question I don't know the answer to off the top of my head, that is, if I do an include of something mapped to an Action, will the Action be executed? What I'm thinking is, what if your include results in an Action execution, and that Action reads in the file you want to include and outputs it to the Response object manually? Then you could access files anywhere on your file system. I think I may be getting too crazy here :) Frank From: Keene, David [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: RE: Custom resource loader Date: Thu, 10 Jun 2004 11:59:10 -0700 That's a good ide frank, but it may not work. FilrDirContext has a normalize method... the javadoc comment says: * Return a context-relative path, beginning with a /, that represents * the canonical version of the specified path after .. and . elements * are resolved out. If the specified path attempts to go outside the * boundaries of the current context (i.e. too many .. path elements * are present), return codenull/code instead. Doh! Also, it would be nice to have the freedom to place the 'common' elsewhere on the system. Dave -Original Message- From: Frank Zammetti [mailto:[EMAIL PROTECTED] Sent: Thursday, June 10, 2004 11:17 AM To: [EMAIL PROTECTED] Subject: RE: Custom resource loader May I suggest one wacky idea? I'm not saying this is GOOD or anything, but it's probably a bit outside the box, for whatever that's worth... What if you had all your common JSPs in a given directory, like so (let's talk Tomcat for a minute, but it doesn't matter)... /tomcat/webapps/commonjsps /tomcat/webapps/webapp1 /tomcat/webapps/webapp2 Then, in either webapp1 or webapp2, let's say you want to use the JSP myJSP1.jsp in the common jsps directory... What if you had a JSP in webapp1 and webapp2 that was just this: %@ page language=java % %@ include file=../commonjsps/myJSP1.jsp.inc % My syntax might be a little off, but I think the concept is clean. You would have to have basically a dummy page that includes the real page, and that could be a pain, but I think this would work, and maybe it's quicker to do than a custom resource loader. Just a thought. Frank From: Keene, David [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Custom resource loader Date: Thu, 10 Jun 2004 10:43:18 -0700 Greetings, A while ago on this list I saw some discussion about custom resource loaders (extending FileDirContext) to load resources from multiple root paths. I am looking specifically to do this in order to grab jsp pages from a 'commons' directory that many of my sites (which run in different contexts) use. Was there any consensus to the right way to do this? Has anyone done this already and would be willing to share? My plan is to send an extra attribute to the Resource tag in the server.xml, which is a comma delimited list of additional paths in the order they should be searched for a given file. The ExtendedDirContext would then keep all the paths on a list and iterate through them until a named resource was located. Any thoughts, Dave Keene - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Looking to buy a house? Get informed with the Home Buying Guide from MSN House Home. http://coldwellbanker.msn.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail
RE: Spawn New Thread
You need to make your thread a daemon thread by calling: myThread.setDaemon(true); That will take care of the shutdown problem. Frank From: Corey Baswell [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Spawn New Thread Date: Wed, 09 Jun 2004 16:18:24 -0500 Hello, I'm trying to figure out what the proper way for spawning a new thread in Tomcat is. I can create a new thread when my servlet is first loaded, but it does not get closed down when tomcat does. Is there anyway to register a new thread with Tomcat so that it will get closed when Tomcat goes down? Thanks for any help, Corey - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Getting married? Find great tips, tools and the latest trends at MSN Life Events. http://lifeevents.msn.com/category.aspx?cid=married - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: JSP page processing time
Do you mean how long it takes to compile, or how long it takes to execute the compiled class? If the former, I don't have an answer. If the later though, try this at the top of your page: long l1 = System.currentTimeMillis(); And then this at the end: long l2 = System.currentTimeMillis(); System.out.println(Execution time: + (l2 - l1)); Make sure it's outside any logic, i.e, that both portions will always execute, and it should do the trick. Frank From: Emre [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: JSP page processing time Date: Thu, 3 Jun 2004 19:30:21 -0400 Is there a method or variable that I can use in a JSP page to display how long it took to process that page. I know PHP has something like that. Does Tomcat have a similar thing for JSPs? Thanx _ Is your PC infected? Get a FREE online computer virus scan from McAfee® Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Problem with request parameters getting mixed with requests from minutes before (PartII)
I had a similar problem a few weeks ago... not exactly the same, but maybe something to consider... The issue I had is that a user would log on to a particular app, and on the bottom of the screen we have a Hello, ! message, where is the user's name. Problem was, people were sometimes getting someone else' name. To make a long story short, what had a proxy server on the network that was improperly caching certain pages of the app, so a request would go through and rather than actually make it to the app server, the proxy would return the cached copy. This was also resulting in sporadic NullPointerExceptions in places in the code that they could never theoretically happen, making it look like request parameters were getting lost. They weren't, it's just that if one request was supposed to set something in session, but that request was fulfilled by the proxy, then naturally another subsequent request would throw an exception because the first never executed to set thing up for it. Like I said, not exactly what you describe, but maybe it's one possibility you can eliminate quickly... could be a network thing, not your app, server or anything related. Frank From: [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Problem with request parameters getting mixed with requests from minutes before (PartII) Date: Fri, 4 Jun 2004 12:53:42 +0900 On Thu, Jun 03, 2004 at 07:41:30PM +0900, ian.wark wrote: : We have a really difficult problem that surfaces only once every week or so : in which request parameters : for requests from a particular mapping get mixed randomly with request : parameters from the same mapping : that occurred minutes before. : : Has anyone come across this before or know why it might be happening? How : we might avoid it? duplicate info for different people usually means instance variable where there should be a method-local variable --There is a request instance variable in the bean, however the action creates a bean for each request inside the control method, so --I can't see there being multiple threads accessing the same instance variable. How are these request params being set? -QM --The short answer is: the application uses the struts framework and on this jsp, submitting is done via JavaScript form submits. Here are some more details. We can tell that is is the same session from the log. So it is the same user. The user does a search and comes up with a list of items. Each item in the list has a link that submits to a details screen that has the details of that particular item. On that screen various information is displayed and there are three buttons below. One called 'check', one called 'back' (ie back to the search list) and another one that is something like 'finished with'. After clicking the 'check' the 'finished with' button becomes pressable. All submitting is done via JavaScript form submits. The problem seems to occur after a sequence similar to the following: 1. User clicks the link to get to the detail screen 2. User clicks the 'check' button which submits the request to itself and updates the check status. 3. The user clicks another button. Which button is not clear because the parameter reads something equivalent to 'check eck' (Japanese equivalent) which does not exist. The button name is taken via JavaScript. The other strange parameter is alarmNo which picks up randomish information after the = sign. Normally there is just one number. Here is an excerpt of one mishappen request from our log. [POST]/AlarmDetail.do?finishUserId=changeConfirmFlg=0addDatet=2004/05/29 09:13:58A13:58confirmExecUpdFlg=0errfilepath =alarmNo=39372=38932dFlg=039583 alarmDetail=etc etc.. We thought at first that the reason might be because the button doesn't have a multiple press lock via Javascript, so that you don't accicentally submit twice. It does have a 'Do you really want to do this' style dialog box. But even if the user managed to submit twice, you don't get two requests getting bunged together. Another very outside chance might be memory leaks. We have closed all the statements in our SQL explicitely, but not the ResultSets. Does that make things little a bit clearer? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Check out the coupons and bargains on MSN Offers! http://youroffers.msn.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: ErrorPage.jsp - how to get the address of the offending page?
Try looking for the attribute request_uri without the whole class specification before it... it still may not be available in Tomcat 3.x, and I've seen reference to looking it up the way you are, but I'm fairly certain that attribute is present in current Tomcat versions as just request_uri, and I'm wondering if maybe it was in that version too. From: Dola Woolfe [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: RE: ErrorPage.jsp - how to get the address of the offending page? Date: Tue, 1 Jun 2004 08:47:07 -0700 (PDT) So am I out of luck or is there an alternative way? --- Mike Curwen [EMAIL PROTECTED] wrote: Yes, that would be the reason. From the corresponding section of the spec for servlet 2.2: If the location of the error handler is a servlet or a JSP, the following request attributes can be set: . javax.servlet.error.status_code . javax.servlet.error.exception_type . javax.servlet.error.message So you'd need tomcat 4 and above for javax.servlet.error.request_uri -Original Message- From: Dola Woolfe [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 01, 2004 3:28 AM To: [EMAIL PROTECTED] Subject: Re: ErrorPage.jsp - how to get the address of the offending page? Does the request attribute javax.servlet.error.request_uri suit your needs ? (from the servlet spec, SRV.9.9.1) Actually returns null. I'm using Tomcat 3; Could that be the reason? Here's my snippet: %@ page isErrorPage=true% % System.out.println(request.getAttribute(javax.servlet.error.r equest_uri)); % - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Learn to simplify your finances and your life in Streamline Your Life from MSN Money. http://special.msn.com/money/0405streamline.armx - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
List question
Sorry to send to everyone, but I checked the info and FAQ responses and couldn't find an answer... How does one switch to list digest mode? Do I need to unsubscribe and re-subscribe, or is there a specific admin command to do so? Thanks everyone, and sorry again for the general list post. Frank W. Zammetti Web Architect Consultant PFPC Global Fund Services - The contents of this email are the property of PNC. If it was not addressed to you, you have no legal right to read it. If you think you received it in error, please notify the sender. Do not forward or copy without permission of the sender. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with database updates using DBCP
Well, some days you just miss the obvious I guess, this is one of those days for me :) Actually though, because of the way this app is architected, that won't work without a fairly significant redesign, which can't be done at this point. We use a single database connection manager class (a fancy way of saying a class that provides implementations of doSelect, doInsert, etc.) that is re-used for the duration of a request. Problem is, during some requests we might be doing a mix of transactions that would require both data soruces. Since the connection is gotten from the data source once in the beginning, there's no good way to know up-front which will be needed. True enough, I could get one of each and use the appropriate one, but getting two connections per request instead of one doesn't strike me as particularly scalable. Well, in any case, there's a small chance I can convince people to move to Tomcat 5 and hopefully this problem goes away with DBCP being the default factory now. Thanks everyone! Frank W. Zammetti Web Architect Consultant PFPC Global Fund Services 760 Moore Road King Of Prussia, PA 19406 Mailstop: F4-F760-2B-3 eMail: [EMAIL PROTECTED] Phone: (610)/382-8243 FAX: (610)/382-8866 Cell: (484)/302-1402 |-+--- | | Riaan Oberholzer| | | riaanoberholzer| | | @yahoo.com | | | | | | 12/24/2003 06:06| | | AM | | | Please respond | | | to Tomcat Users| | | List | | | | |-+--- --| | | |To: Tomcat Users List [EMAIL PROTECTED] | |cc: | |Subject: Re: Problem with database updates using DBCP | --| Create 2 datasources and configure one to do auto commit and one not. If you need the auto-commit ('single' insert, delete or updates calls), use that datasource... if you want to do batch queries, use the other and do the commit manually. --- [EMAIL PROTECTED] wrote:Creat I was about to try that, but I had a thought... wouldn't that mean that batch transactions could not be used? I say that because, as I understand it, you are supposed to explicitly turn off autocommit when committing a batch, which only makes sense I think. If I specify at the data source level autocommit should be turned on, wouldn't that by definition mean I couldn't do batches? If that is the case, then even if your suggestion works I couldn't use it because about half of my database writes are in fact batches (I should point out that right now they fail the same as a single insert, update or delete does). Frank W. Zammetti Web Architect Consultant PFPC Global Fund Services 760 Moore Road King Of Prussia, PA 19406 Mailstop: F4-F760-2B-3 eMail: [EMAIL PROTECTED] Phone: (610)/382-8243 FAX: (610)/382-8866 Cell: (484)/302-1402 |-+--- | | Philipp Taprogge| | | Philipp.Taprogg| | | [EMAIL PROTECTED] | | | | | | 12/23/2003 02:29| | | PM | | | Please respond | | | to Tomcat Users| | | List | | | | |-+--- --| | | |To: Tomcat Users List [EMAIL PROTECTED] | |cc: | |Subject: Re: Problem with database updates using DBCP | --| Hi! David Ramsey wrote: I've not used DBCP specifically but are you sure you are committing your writes? Most pools will default rollback connections returned to the pool, if I am not mistaken. Isn't there a parameter autocommit in the ConnectionFactory? I am not sure if it's viable to call setAutoCommit() on a connection obtained from the
Re: Problem with database updates using DBCP
Just wanted to let everyone know that I convinced the powers that be here at work to upgrade to 5.0.16 for this project, and lo and behold all my problems went away! Not a single line of code was changed, only two configuration parameters changed (username became user and driverName became url in the server.xml entry), and everything is now working as expected. Considerably snappier performance as well. I wish I knew what the issue was, but I'll live with never knowing now that things are working right. Thanks for all the suggestions tossed my way! --- Hello all. I've recently had a need to implement connection pooling under Tomcat 4.0.6 (I can't upgrade versions as per a mandate by my employer). I have read some posts that indicate that Tyrex does not actually pool connections. I don't know for sure if that is true or not (any definitive answers here?), so I decided to use DBCP, since I knew that did. I grabbed the latest builds of DBCP, collections and pool (1.1, 2.1 and 1.1 respectively), stuck them in tomcat/common/lib, added my JNDI entry to the app's context in server.xml, added the proper ref tags in web.xml and put in the appropriate code to get a connection from the pool (set to maxActive=50, maxIdle=5, maxWait=1000 and minIdle=10). Now, I've got it up and running without much trouble. Everything SEEMED to be working fine, until I realized that all my database writes (updates, inserts, deletes) were NOT hitting the database. There are NO exceptions being thrown anywhere of any kind. All the relevant objects (statements, connection, etc.) are non-null. Return codes from SQL executions where applicable seem to be what they should be. Database reads work perfectly, which indicates everything is OK I think (I have a single class with a single method that gets the connection out of the pool and deals with all database access). My question is simple and obvious: anyone have any ideas why database writes would be failing (maybe failing is the wrong word... simply not happening is more accurate) while reads succeed? It is an Oracle 9.2 database by the way, using the Oracle thin JDBC driver (same driver that is used when I switch to manually creating connections in code rather than using JNDI and Tomcat's facilities). Frank W. Zammetti Web Architect Consultant - The contents of this email are the property of PNC. If it was not addressed to you, you have no legal right to read it. If you think you received it in error, please notify the sender. Do not forward or copy without permission of the sender. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem with database updates using DBCP
Hello all. I've recently had a need to implement connection pooling under Tomcat 4.0.6 (I can't upgrade versions as per a mandate by my employer). I have read some posts that indicate that Tyrex does not actually pool connections. I don't know for sure if that is true or not (any definitive answers here?), so I decided to use DBCP, since I knew that did. I grabbed the latest builds of DBCP, collections and pool (1.1, 2.1 and 1.1 respectively), stuck them in tomcat/common/lib, added my JNDI entry to the app's context in server.xml, added the proper ref tags in web.xml and put in the appropriate code to get a connection from the pool (set to maxActive=50, maxIdle=5, maxWait=1000 and minIdle=10). Now, I've got it up and running without much trouble. Everything SEEMED to be working fine, until I realized that all my database writes (updates, inserts, deletes) were NOT hitting the database. There are NO exceptions being thrown anywhere of any kind. All the relevant objects (statements, connection, etc.) are non-null. Return codes from SQL executions where applicable seem to be what they should be. Database reads work perfectly, which indicates everything is OK I think (I have a single class with a single method that gets the connection out of the pool and deals with all database access). My question is simple and obvious: anyone have any ideas why database writes would be failing (maybe failing is the wrong word... simply not happening is more accurate) while reads succeed? It is an Oracle 9.2 database by the way, using the Oracle thin JDBC driver (same driver that is used when I switch to manually creating connections in code rather than using JNDI and Tomcat's facilities). Frank W. Zammetti Web Architect Consultant - The contents of this email are the property of PNC. If it was not addressed to you, you have no legal right to read it. If you think you received it in error, please notify the sender. Do not forward or copy without permission of the sender. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with database updates using DBCP
Yep, I thought of that too. But, I explicitly call conn.setAutoCommit(true); before every update, insert or delete. When batching I call it with false and then executeBatch, and calling rollback if the batch fails, all pretty typical code I think. Is there anything else I should be doing do you think? Should I explicitly call commit() after a successful executeUpdate() (I haven't tried that, you just made me think of it - seems like overkill, but maybe?) Frank W. Zammetti Web Architect Consultant PFPC Global Fund Services 760 Moore Road King Of Prussia, PA 19406 Mailstop: F4-F760-2B-3 eMail: [EMAIL PROTECTED] Phone: (610)/382-8243 FAX: (610)/382-8866 Cell: (484)/302-1402 |-+--- | | David Ramsey| | | david_l_ramsey@| | | yahoo.com | | | | | | 12/23/2003 02:03| | | PM | | | Please respond | | | to Tomcat Users| | | List | | | | |-+--- --| | | |To: Tomcat Users List [EMAIL PROTECTED] | |cc: | |Subject: Re: Problem with database updates using DBCP | --| I've not used DBCP specifically but are you sure you are committing your writes? Most pools will default rollback connections returned to the pool, if I am not mistaken. --- [EMAIL PROTECTED] wrote: Hello all. I've recently had a need to implement connection pooling under Tomcat 4.0.6 (I can't upgrade versions as per a mandate by my employer). I have read some posts that indicate that Tyrex does not actually pool connections. I don't know for sure if that is true or not (any definitive answers here?), so I decided to use DBCP, since I knew that did. I grabbed the latest builds of DBCP, collections and pool (1.1, 2.1 and 1.1 respectively), stuck them in tomcat/common/lib, added my JNDI entry to the app's context in server.xml, added the proper ref tags in web.xml and put in the appropriate code to get a connection from the pool (set to maxActive=50, maxIdle=5, maxWait=1000 and minIdle=10). Now, I've got it up and running without much trouble. Everything SEEMED to be working fine, until I realized that all my database writes (updates, inserts, deletes) were NOT hitting the database. There are NO exceptions being thrown anywhere of any kind. All the relevant objects (statements, connection, etc.) are non-null. Return codes from SQL executions where applicable seem to be what they should be. Database reads work perfectly, which indicates everything is OK I think (I have a single class with a single method that gets the connection out of the pool and deals with all database access). My question is simple and obvious: anyone have any ideas why database writes would be failing (maybe failing is the wrong word... simply not happening is more accurate) while reads succeed? It is an Oracle 9.2 database by the way, using the Oracle thin JDBC driver (same driver that is used when I switch to manually creating connections in code rather than using JNDI and Tomcat's facilities). Frank W. Zammetti Web Architect Consultant - The contents of this email are the property of PNC. If it was not addressed to you, you have no legal right to read it. If you think you received it in error, please notify the sender. Do not forward or copy without permission of the sender. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - The contents of this email are the property of PNC. If it was not addressed to you, you have no legal right to read it. If you think you received it in error, please notify the sender. Do not forward or copy without permission of the sender.
Re: Problem with database updates using DBCP
Good info, thank you Justin! Unfortunately, it didn't solve my problem, but I will leave the commits there regardless. Thanks again! Any other suggestions out there? Can anyone verify if Tyrex, as shipped with 4.0.6, does in fact pool connections? I could always drop back and punt to that. Frank W. Zammetti Web Architect Consultant PFPC Global Fund Services 760 Moore Road King Of Prussia, PA 19406 Mailstop: F4-F760-2B-3 eMail: [EMAIL PROTECTED] Phone: (610)/382-8243 FAX: (610)/382-8866 Cell: (484)/302-1402 |-+--- | | Justin | | | Ruthenbeck | | | [EMAIL PROTECTED]| | | ine.com| | | | | | 12/23/2003 02:25| | | PM | | | Please respond | | | to Tomcat Users| | | List | | | | |-+--- --| | | |To: Tomcat Users List [EMAIL PROTECTED] | |cc: | |Subject: Re: Problem with database updates using DBCP | --| At 11:10 AM 12/23/2003, you wrote: Yep, I thought of that too. But, I explicitly call conn.setAutoCommit(true); before every update, insert or delete. When batching I call it with false and then executeBatch, and calling rollback if the batch fails, all pretty typical code I think. Is there anything else I should be doing do you think? Should I explicitly call commit() after a successful executeUpdate() (I haven't tried that, you just made me think of it - seems like overkill, but maybe?) Don't rely on the setAutoCommit(boolean) method to do anything -- I have seen appservers/conn pools that do not support the method and ignore your suggestion (early 3.X jBoss comes to mind), always using the hard-configured values. Always explicitly call either commit() or rollback() to insulate yourself from these details. Merry Christmas! justin | |To: Tomcat Users List [EMAIL PROTECTED] | |cc: | |Subject: Re: Problem with database updates using DBCP | --| I've not used DBCP specifically but are you sure you are committing your writes? Most pools will default rollback connections returned to the pool, if I am not mistaken. --- [EMAIL PROTECTED] wrote: Hello all. I've recently had a need to implement connection pooling under Tomcat 4.0.6 (I can't upgrade versions as per a mandate by my employer). I have read some posts that indicate that Tyrex does not actually pool connections. I don't know for sure if that is true or not (any definitive answers here?), so I decided to use DBCP, since I knew that did. I grabbed the latest builds of DBCP, collections and pool (1.1, 2.1 and 1.1 respectively), stuck them in tomcat/common/lib, added my JNDI entry to the app's context in server.xml, added the proper ref tags in web.xml and put in the appropriate code to get a connection from the pool (set to maxActive=50, maxIdle=5, maxWait=1000 and minIdle=10). Now, I've got it up and running without much trouble. Everything SEEMED to be working fine, until I realized that all my database writes (updates, inserts, deletes) were NOT hitting the database. There are NO exceptions being thrown anywhere of any kind. All the relevant objects (statements, connection, etc.) are non-null. Return codes from SQL executions where applicable seem to be what they should be. Database reads work perfectly, which indicates everything is OK I think (I have a single class with a single method that gets the connection out of the pool and deals with all database access). My question is simple and obvious: anyone have any ideas why database writes would be failing (maybe failing is the wrong word... simply not happening is more accurate) while reads succeed? It is an Oracle 9.2 database by the way, using the Oracle thin JDBC driver (same driver that is used when I switch to manually creating connections in code rather than
Re: Problem with database updates using DBCP
I was about to try that, but I had a thought... wouldn't that mean that batch transactions could not be used? I say that because, as I understand it, you are supposed to explicitly turn off autocommit when committing a batch, which only makes sense I think. If I specify at the data source level autocommit should be turned on, wouldn't that by definition mean I couldn't do batches? If that is the case, then even if your suggestion works I couldn't use it because about half of my database writes are in fact batches (I should point out that right now they fail the same as a single insert, update or delete does). Frank W. Zammetti Web Architect Consultant PFPC Global Fund Services 760 Moore Road King Of Prussia, PA 19406 Mailstop: F4-F760-2B-3 eMail: [EMAIL PROTECTED] Phone: (610)/382-8243 FAX: (610)/382-8866 Cell: (484)/302-1402 |-+--- | | Philipp Taprogge| | | Philipp.Taprogg| | | [EMAIL PROTECTED] | | | | | | 12/23/2003 02:29| | | PM | | | Please respond | | | to Tomcat Users| | | List | | | | |-+--- --| | | |To: Tomcat Users List [EMAIL PROTECTED] | |cc: | |Subject: Re: Problem with database updates using DBCP | --| Hi! David Ramsey wrote: I've not used DBCP specifically but are you sure you are committing your writes? Most pools will default rollback connections returned to the pool, if I am not mistaken. Isn't there a parameter autocommit in the ConnectionFactory? I am not sure if it's viable to call setAutoCommit() on a connection obtained from the pool. Try specifying autocommit in the DataSource declaration. Phil - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - The contents of this email are the property of PNC. If it was not addressed to you, you have no legal right to read it. If you think you received it in error, please notify the sender. Do not forward or copy without permission of the sender. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]