Handling auth failure

2003-07-21 Thread Christian J. Dechery - ACCENTURE
I have successfully implemented authentication in Tomcat, but I don't want
that 403 screen to ever show up.
 
Is that possible? I'd like that, for whatever reason, the login screen would
always show indicating an authentication failure and requesting a new login.
If that's not possible, how can I change that ugly default 403 screen?
 
thanks

___
:: Christian J. Dechery 
:: Accenture do Brasil 
:: CHT - Solutions Operations 
:: [EMAIL PROTECTED] 

 


RES: Handling auth failure

2003-07-21 Thread Christian J. Dechery - ACCENTURE
where exactly in web.xml does this error-page go?

___
:: Christian J. Dechery
:: Accenture do Brasil
:: CHT - Solutions Operations
:: [EMAIL PROTECTED]


 -Mensagem original-
 De: Abid Ali Teepo [mailto:[EMAIL PROTECTED]
 Enviada em: segunda-feira, 21 de julho de 2003 10:41
 Para: Tomcat Users List
 Assunto: RE: Handling auth failure
 
 
 Add this to your web.xml and make a page called error.jsp .
 
 
   error-page
   error-code403/error-code 
   location/error.jsp/location 
   /error-page
 
 -Original Message-
 From: Christian J. Dechery - ACCENTURE
 [mailto:[EMAIL PROTECTED]
 Sent: 21. juli 2003 15:37
 To: Tomcat Users List (E-mail)
 Subject: Handling auth failure
 
 
 I have successfully implemented authentication in Tomcat, but 
 I don't want
 that 403 screen to ever show up.
  
 Is that possible? I'd like that, for whatever reason, the 
 login screen would
 always show indicating an authentication failure and 
 requesting a new login.
 If that's not possible, how can I change that ugly default 403 screen?
  
 thanks
 
 ___
 :: Christian J. Dechery 
 :: Accenture do Brasil 
 :: CHT - Solutions Operations 
 :: [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]



Invalid direct reference to form login page

2003-07-21 Thread Christian J. Dechery - ACCENTURE
Sometimes I get this error message... can someone give me a hint on the
probable causes??

___
:: Christian J. Dechery 
:: Accenture do Brasil 
:: CHT - Solutions Operations 
:: [EMAIL PROTECTED] 

 


RES: Invalid direct reference to form login page

2003-07-21 Thread Christian J. Dechery - ACCENTURE
yeah... I figured that.

I have a logoff page, and it used to call the login in case the user wanted
the re-authenticate... now I just have to link to the index page instead of
the login page and everything works fine.

Thanks!

___
:: Christian J. Dechery
:: Accenture do Brasil
:: CHT - Solutions Operations
:: [EMAIL PROTECTED]


 -Mensagem original-
 De: Abid Ali Teepo [mailto:[EMAIL PROTECTED]
 Enviada em: segunda-feira, 21 de julho de 2003 11:22
 Para: Tomcat Users List
 Assunto: RE: Invalid direct reference to form login page
 
 
 
 Usually you are interested in some secured resource, and you 
 try to get it.
 Because it's secured you will be redirected to a login-page, 
 and after authenticating yourself you will be redirected to 
 the requested resource.
 
 If you go directly to the login-page, where will it redirect 
 you when you are loged in ?
 
 This is the cause ...
 
 Abid
 
 -Original Message-
 From: Christian J. Dechery - ACCENTURE
 [mailto:[EMAIL PROTECTED]
 Sent: 21. juli 2003 16:09
 To: Tomcat Users List (E-mail)
 Subject: Invalid direct reference to form login page
 
 
 Sometimes I get this error message... can someone give me a 
 hint on the
 probable causes??
 
 ___
 :: Christian J. Dechery 
 :: Accenture do Brasil 
 :: CHT - Solutions Operations 
 :: [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]



Querying container's user database

2003-07-16 Thread Christian J. Dechery - ACCENTURE
Is there a way I can query the container's user database to find out if a
specifed login exists or not??
 
If yes, is the solution container-specific?

___
:: Christian J. Dechery 
:: Accenture do Brasil 
:: CHT - Solutions Operations 
:: [EMAIL PROTECTED] 

 


RES: unable to access after password change

2003-07-16 Thread Christian J. Dechery - ACCENTURE
Where (how) did u change the password?

check TOMCAT_DIR/conf/tomcat-users.xml to see if ur using the correct
password.

___
:: Christian J. Dechery
:: Accenture do Brasil
:: CHT - Solutions Operations
:: [EMAIL PROTECTED]


 -Mensagem original-
 De: epyonne =) [mailto:[EMAIL PROTECTED]
 Enviada em: quarta-feira, 16 de julho de 2003 11:43
 Para: [EMAIL PROTECTED]
 Assunto: unable to access after password change
 
 
 Hello All,
 
 When I installed Tomcat, I used admin/admin for username and 
 password.  This 
 morning I changed the password to be more secure.  After 
 that, I cannot 
 access the manager or the administration page anymore.  Even 
 by restarting 
 Tomcat.  All I got is:
 HTTP Status 403 - Access to the requested resource has been denied
 
 Does anyone know why?  and how to resolve it?  I hope I don't have to 
 re-install Tomcat.
 
 Thank you very much.
 
 _
 Protect your PC - get McAfee.com VirusScan Online  
 http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
 
 
 -
 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]



RES: Querying container's user database

2003-07-16 Thread Christian J. Dechery - ACCENTURE
So I'm screwed? hehehehe

I don't know if u've seen my post about logging off container's
authenticated users. Can u please check it out, U seem to know about the
subject. Thanks

___
:: Christian J. Dechery
:: Accenture do Brasil
:: CHT - Solutions Operations
:: [EMAIL PROTECTED]


 -Mensagem original-
 De: Tim Funk [mailto:[EMAIL PROTECTED]
 Enviada em: quarta-feira, 16 de julho de 2003 14:21
 Para: Tomcat Users List
 Assunto: Re: Querying container's user database
 
 
 Its container specific. Also to do so - the Realm would have 
 to provide that 
 ability - so even this is Realm specfic too.
 
 http://jakarta.apache.org/tomcat/tomcat-4.1-doc/realm-howto.html
 
 And to top if off - You app will need to be be a privledged 
 webapp so it 
 may see the catalina internals. (which is where realms live)
 
 -Tim
 
 
 Christian J. Dechery - ACCENTURE wrote:
  Is there a way I can query the container's user database to 
 find out if a
  specifed login exists or not??
   
  If yes, is the solution container-specific?
  
 
 
 -
 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]



RES: RES: Querying container's user database

2003-07-16 Thread Christian J. Dechery - ACCENTURE
yeah, I tought of that... I haven't tried invalidate(), but I watched the
session data after the user is authenticated, and it's EMPTY, there's
nothing... where's the user data? Is it hidden??

___
:: Christian J. Dechery
:: Accenture do Brasil
:: CHT - Solutions Operations
:: [EMAIL PROTECTED]


 -Mensagem original-
 De: Tim Funk [mailto:[EMAIL PROTECTED]
 Enviada em: quarta-feira, 16 de julho de 2003 14:58
 Para: Tomcat Users List
 Assunto: Re: RES: Querying container's user database
 
 
 If all the auth data is in the session (with FORM based auth 
 it usually is) - 
 then invalidate the session via session.invalidate()
 
 -Tim
 
 Christian J. Dechery - ACCENTURE wrote:
  So I'm screwed? hehehehe
  
  I don't know if u've seen my post about logging off container's
  authenticated users. Can u please check it out, U seem to 
 know about the
  subject. Thanks
  
  ___
  :: Christian J. Dechery
  :: Accenture do Brasil
  :: CHT - Solutions Operations
  :: [EMAIL PROTECTED]
  
  
  
 -Mensagem original-
 De: Tim Funk [mailto:[EMAIL PROTECTED]
 Enviada em: quarta-feira, 16 de julho de 2003 14:21
 Para: Tomcat Users List
 Assunto: Re: Querying container's user database
 
 
 Its container specific. Also to do so - the Realm would have 
 to provide that 
 ability - so even this is Realm specfic too.
 
 http://jakarta.apache.org/tomcat/tomcat-4.1-doc/realm-howto.html
 
 And to top if off - You app will need to be be a privledged 
 webapp so it 
 may see the catalina internals. (which is where realms live)
 
 -Tim
 
 
 Christian J. Dechery - ACCENTURE wrote:
 
 Is there a way I can query the container's user database to 
 
 find out if a
 
 specifed login exists or not??
  
 If yes, is the solution container-specific?
 
 
 
 
 -
 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]
  
  
 
 
 -
 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]



Logging off container authenticated user

2003-07-15 Thread Christian J. Dechery - ACCENTURE
I finally got a FORM-based authentication from the container (in this case,
Tomcat) working.
 
But I have a little doubt, how can I logoff this user?
 
Cuz in my system, the login doesn't deppend only on authenticating him for
username and password, I must validate some other stuff, so it would be
interesting if I could authenticate him, and if I could not validate the
other stuff, log him off and present a message.
 
Thanks.

___
:: Christian J. Dechery 
:: Accenture do Brasil 
:: CHT - Solutions Operations 
:: [EMAIL PROTECTED] 

 


two instances of tomcat (in diferent ports) on the samemachine

2002-09-19 Thread Christian J. Dechery

How can I achieve this? Is it possible?
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332



RE: two instances of tomcat (in diferent ports) on the samemachine

2002-09-19 Thread Christian J. Dechery

I tried that... but I get some kind of conflict with CATALINA_HOME...
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 09/19 4:52 pm 

Yes, this is absolutely possible.  I have 13 instances (Tomcat 3.1)
running
on a single server at the moment.

You will need a different server.xml for each, a different work
directory
for each, and each must be on its own connector port (whichever
connector
you choose to use).  At least, that is how it is set up on my server.

John

 -Original Message-
 From: Christian J. Dechery [mailto:[EMAIL PROTECTED]] 
 Sent: Thursday, September 19, 2002 3:48 PM
 To: [EMAIL PROTECTED] 
 Subject: two instances of tomcat (in diferent ports) on the 
 same machine
 
 
 How can I achieve this? Is it possible?
  
 .:| Christian J. Dechery
 .:| FINEP - Depto. de Sistemas
 .:| [EMAIL PROTECTED] 
 .:| (21) 2555-0332
 

--
To unsubscribe, e-mail:  
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]





problems with browser cache

2002-09-04 Thread Christian J. Dechery

How can I prevent the broswer from using the cache when loading a JSP with a 100% 
certainty?
 
I'm experiencing a reaaally weird cache problem... I have a page that includes 
items in table, and when an item is included it reloads itself so the new item can be 
shown, but sometimes the new item shows, and sometimes it doesn't... I even play with 
the refresh because it's completely random.
 
Even if I delete the item, it sometimes still shows...
 
I put this line at the top of my JSP but it seems not to acomplish anything...
% response.setHeader (Pragma, no-cache); %
 
any ideas??
 
thanks
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332




RE: problems with Connections

2002-08-22 Thread Christian J. Dechery

This is how it is being done now... and it works, but it's veery slow... 
in some reports that uses a lot of classes, and of course a bunch of queries it takes 
almost 3minutes to load the report page...
 
there's gotta be a better solution
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 21/08/02 17:02 
Every method will have to get it's own connection and close it too.

 -Original Message-
 From: Christian J. Dechery [mailto:[EMAIL PROTECTED]] 
 Sent: Wednesday, August 21, 2002 2:56 PM
 To: [EMAIL PROTECTED] 
 Subject: Re: problems with Connections
 
 
 That's exactly the problem... we dont't have any servlets (I 
 wish we had, but I didn't design, I only code)... only JSPs 
 and classes... 
  
 I'll give u an example of how are things here... let's say we 
 have a class called BusinessObject, and a class called 
 DAOBusinessObject...
  
 so I'd have a JSP like that
  
 %
 BusinessObject bo = new BusinessObject(); // at this 
 point, DAOBusinessObject requested a connection
 bo.method1(); // this method calls a method in DAO which 
 runs a query
 bo.method2(); // this on too... and every other method as well...
 %
  
 so, as long as the DAOBusinessObject object lives the 
 Connection is there... how am I supposed to close it, since 
 every query needs it? Now I see, I should have a method to 
 close the used conn or something... but we have up to 50 DAO* 
 classes and more then 200 JSPs... 
  
 I agree with what u said about the finalize()... but what 
 should I do then?
  
  
 .:| Christian J. Dechery
 .:| FINEP - Depto. de Sistemas
 .:| [EMAIL PROTECTED] 
 .:| (21) 2555-0332
 
  [EMAIL PROTECTED] 21/08/02 16:37 
 
 
 On Wed, 21 Aug 2002, Christian J. Dechery wrote:
 
  Date: Wed, 21 Aug 2002 16:13:23 -0300
  From: Christian J. Dechery [EMAIL PROTECTED]
  Reply-To: Tomcat Users List [EMAIL PROTECTED]
  To: [EMAIL PROTECTED] 
  Subject: Re: problems with Connections
 
  I don't think it is TOTALLY offtopic, since the problem 
 occurs within
  Tomcat...
 
 From your description of the problem and your design 
 approach, I'll bet it
 would happen to you in a long-running non-servlet application as well.
 
 and when I close tomcat all the connections and cursors are
  released...
 
 
 Exactly what you'd expect if your application is leaking open 
 connections,
 statements, or result sets.
 
  as I said in my email I close ALL ResultSets and Statements 
 in finally
  blocks...
 
 
 Fine, I'll take your word for it ... but missing a case would easily
 account for what you are seeing.  (In the particular case of Oracle, a
 cursor is allocated for each result set, which is not 
 released until the
 result set is closed).
 
  as for closing the Connection... can I use the finalize() 
 in the DAO*
  classes to use the method that returns the Connection to 
 the pool?? Cuz
  I can't see anywhere else where I'd be able to do that...
 
 
 The right design pattern is to acquire a connection, do whatever
 processing is required, and immediately release it.  For example:
 
   DataSource dataSource = ...;  // Acquire reference to 
 connection pool
   Connection conn = null;
   try {
 conn = dataSource.getConnection();
 ... perform SQL operations as necessary ...
 conn.close(); // Return connection to the pool
 conn = null;
   } catch (SQLException e) {
 ... deal with problems ...
   } finally {
 if (conn != null) {
   try {
 conn.close();  // Return to pool even if an exception occurred
   } catch (SQLException e) {
 ;
   }
   conn = null;
 }
   }
 
 Waiting for the finalize() method to clean up just occupies resources
 needlessly until the garbage collector gets around to running -- this
 by itself could easily exhaust your available connections in a busy
 environment.  It also assumes that your JDBC driver's 
 implementation of
 the finalize() method knows that this Connection was stored in a pool.
 That seems like a really shaky bet.
 
 A primary goal of your designs should be to minimize the 
 amount of time
 that you have a database connection allocated to the processing of a
 particular request -- connections are expensive to create, and there's
 always an upper limit on how many your database will support.
 
  .:| Christian J. Dechery
  .:| FINEP - Depto. de Sistemas
  .:| [EMAIL PROTECTED] 
  .:| (21) 2555-0332
 
 Craig
 
 
 --
 To unsubscribe, e-mail:   
mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]






Re: problems with Connections

2002-08-22 Thread Christian J. Dechery

I wish it was that simple to just DO-IT-ALL-OVER-AGAIN but we're already in 
production, I don't have the time to go trough all the classes again an rewrite 
code... I have a lot of other things to do along with providing maintenance to all 
these 100 classes...
 
Isn't there a way a class can have a connection and properly close it after it has 
made use of it? Cuz that's the main problem here... the connections don't close... 
only if I call con.close() in the same method that opens it... but that makes it too 
slow...
 
And what about that maximum cursors open thing?? I call rs.close() and stmt.close() 
in the finally block of EVERY query... how come I get maxium cursors???
 
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 22/08/02 00:58 


On Wed, 21 Aug 2002, Christian J. Dechery wrote:

 Date: Wed, 21 Aug 2002 16:56:05 -0300
 From: Christian J. Dechery [EMAIL PROTECTED]
 Reply-To: Tomcat Users List [EMAIL PROTECTED]
 To: [EMAIL PROTECTED] 
 Subject: Re: problems with Connections

 That's exactly the problem... we dont't have any servlets (I wish we had, but I 
didn't design, I only code)... only JSPs and classes...

 I'll give u an example of how are things here... let's say we have a class called 
BusinessObject, and a class called DAOBusinessObject...

 so I'd have a JSP like that

 %
 BusinessObject bo = new BusinessObject(); // at this point, DAOBusinessObject 
requested a connection
 bo.method1(); // this method calls a method in DAO which runs a query
 bo.method2(); // this on too... and every other method as well...
 %
  so, as long as the DAOBusinessObject object lives the Connection is
 there... how am I supposed to close it, since every query needs it? Now
 I see, I should have a method to close the used conn or something... but
 we have up to 50 DAO* classes and more then 200 JSPs...

 I agree with what u said about the finalize()... but what should I do then?


Give up and start over.

Seriously.

This application design is totally hopeless from a scalability or
reliability viewpoint, because it requires a connection for every business
object, on every page that uses that BO class.  To say nothing of the fact
that JDBC drivers are not required to be thread safe, so you're
undoubtedly causing yourself tremendous grief when the same page is
accessed by more than one user.

If you follow my advice, please follow one other piece -- get a book on
design patterns (Core J2EE Design Patterns by Alur/Crupi/Malks is one of
my most well-thumbed resources) and follow the prescribed patterns for
doing this right.


 .:| Christian J. Dechery
 .:| FINEP - Depto. de Sistemas
 .:| [EMAIL PROTECTED] 
 .:| (21) 2555-0332


Craig


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]






problems with Connections

2002-08-21 Thread Christian J. Dechery

I have this big problem handling Oracle Connecions...
 
something goes wrong... I have tons of classes called DAOSomething... and a class 
called DAO which provides the Connection... the DAO*s requests the Connection from DAO 
and uses it, but there is no method to close the connection since it is used by 
several methods that run queries (selects and updates)...
 
I don't know what goes wrong... but after some time of using the applicatiob the 
maximum number of cursors exceeds and the whole application stops, cuz no more queries 
will run... and I am closing ALL ResultSets and Statements on the finally block of 
EVERY query...
 
this happend when I dispense one Connection to several classes, thus achieving some 
kind of sharing... if I turn that sharing off - every class will get an exclusive 
Connection, the problem changes... now instead of the maximum number of cursors 
exceeding, I get maximum number of processes (connections)...
 
the connections (nor the cursors for that matter) are getting closed... I even tried 
placing a con.close() on the finalize() method of the DAO*s... but that didn't work... 
I get an IOException: socket closed...
 
At the Oracle support service, I saw that a lot of people has the exact same problem..
 
does anyone knows how to solve this???
 
thanks
 
btw: I have a solution working now... I changed the code of my DAO*s, so that every 
method that runs a query, requests a connection, than closes it... but that makes some 
parts of the application very slow...
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332




RE: problems with Connections

2002-08-21 Thread Christian J. Dechery

already tried that... didn't work... as a matter of fact, the pool had no effect on 
the problem, it stayed the same...
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 21/08/02 15:12 
You need a connection pooler.  The Oracle Drivers come with support for connection 
pooling.

 -Original Message-
 From: Christian J. Dechery [mailto:[EMAIL PROTECTED]] 
 Sent: Wednesday, August 21, 2002 1:01 PM
 To: [EMAIL PROTECTED] 
 Subject: problems with Connections
 
 
 I have this big problem handling Oracle Connecions...
  
 something goes wrong... I have tons of classes called 
 DAOSomething... and a class called DAO which provides the 
 Connection... the DAO*s requests the Connection from DAO and 
 uses it, but there is no method to close the connection since 
 it is used by several methods that run queries (selects and 
 updates)...
  
 I don't know what goes wrong... but after some time of using 
 the applicatiob the maximum number of cursors exceeds and the 
 whole application stops, cuz no more queries will run... and 
 I am closing ALL ResultSets and Statements on the finally 
 block of EVERY query...
  
 this happend when I dispense one Connection to several 
 classes, thus achieving some kind of sharing... if I turn 
 that sharing off - every class will get an exclusive 
 Connection, the problem changes... now instead of the maximum 
 number of cursors exceeding, I get maximum number of 
 processes (connections)...
  
 the connections (nor the cursors for that matter) are getting 
 closed... I even tried placing a con.close() on the 
 finalize() method of the DAO*s... but that didn't work... I 
 get an IOException: socket closed...
  
 At the Oracle support service, I saw that a lot of people has 
 the exact same problem..
  
 does anyone knows how to solve this???
  
 thanks
  
 btw: I have a solution working now... I changed the code of 
 my DAO*s, so that every method that runs a query, requests a 
 connection, than closes it... but that makes some parts of 
 the application very slow...
  
 .:| Christian J. Dechery
 .:| FINEP - Depto. de Sistemas
 .:| [EMAIL PROTECTED] 
 .:| (21) 2555-0332
 
 

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]






Re: problems with Connections

2002-08-21 Thread Christian J. Dechery

from the pool, of course... 
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 21/08/02 15:36 
On Wed, Aug 21, 2002 at 03:28:09PM -0300, Christian J. Dechery wrote:
 already tried that... didn't work... as a matter of fact, the pool
 had no effect on the problem, it stayed the same...

re: using connection pooling

did you get the connection from the pool or did you use the driver
manager to create one yourself?

-- 
Peter Abplanalp

Email:   [EMAIL PROTECTED] 
PGP: pgp.mit.edu





Re: problems with Connections

2002-08-21 Thread Christian J. Dechery

I don't think it is TOTALLY offtopic, since the problem occurs within Tomcat... and 
when I close tomcat all the connections and cursors are released...
 
as I said in my email I close ALL ResultSets and Statements in finally blocks...
 
as for closing the Connection... can I use the finalize() in the DAO* classes to use 
the method that returns the Connection to the pool?? Cuz I can't see anywhere else 
where I'd be able to do that...
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 21/08/02 15:32 
This is totally off topic for TOMCAT-USER, but ...

The basic rules for successful use of a connection pool:

* Always close the connection before the current request completes
  (which doesn't really close the underlying Connection; it just
  returns it to the pool.

* Always close your ResultSet and Statement instances when you
  are through with them -- a finally clause is good for this.
  It sounds like you have missed some error cases.

* Never try to share an individual Connection across more than
  one request -- Connection instances are *not* shareable.  That's
  why you're using a connection pool in the first place.

I suspect that your code is violating one or more of these principles --
probably on some rarely executed code path (because it takes some time for
the problem to surface).

Craig


On Wed, 21 Aug 2002, Christian J. Dechery wrote:

 Date: Wed, 21 Aug 2002 15:01:04 -0300
 From: Christian J. Dechery [EMAIL PROTECTED]
 Reply-To: Tomcat Users List [EMAIL PROTECTED]
 To: [EMAIL PROTECTED] 
 Subject: problems with Connections

 I have this big problem handling Oracle Connecions...

 something goes wrong... I have tons of classes called DAOSomething... and a class 
called DAO which provides the Connection... the DAO*s requests the Connection from 
DAO and uses it, but there is no method to close the connection since it is used by 
several methods that run queries (selects and updates)...

 I don't know what goes wrong... but after some time of using the applicatiob the 
maximum number of cursors exceeds and the whole application stops, cuz no more 
queries will run... and I am closing ALL ResultSets and Statements on the finally 
block of EVERY query...

 this happend when I dispense one Connection to several classes, thus achieving some 
kind of sharing... if I turn that sharing off - every class will get an exclusive 
Connection, the problem changes... now instead of the maximum number of cursors 
exceeding, I get maximum number of processes (connections)...

 the connections (nor the cursors for that matter) are getting closed... I even tried 
placing a con.close() on the finalize() method of the DAO*s... but that didn't 
work... I get an IOException: socket closed...

 At the Oracle support service, I saw that a lot of people has the exact same 
problem..

 does anyone knows how to solve this???

 thanks

 btw: I have a solution working now... I changed the code of my DAO*s, so that 
every method that runs a query, requests a connection, than closes it... but that 
makes some parts of the application very slow...

 .:| Christian J. Dechery
 .:| FINEP - Depto. de Sistemas
 .:| [EMAIL PROTECTED] 
 .:| (21) 2555-0332




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]






Re: problems with Connections

2002-08-21 Thread Christian J. Dechery

That's exactly the problem... we dont't have any servlets (I wish we had, but I didn't 
design, I only code)... only JSPs and classes... 
 
I'll give u an example of how are things here... let's say we have a class called 
BusinessObject, and a class called DAOBusinessObject...
 
so I'd have a JSP like that
 
%
BusinessObject bo = new BusinessObject(); // at this point, DAOBusinessObject 
requested a connection
bo.method1(); // this method calls a method in DAO which runs a query
bo.method2(); // this on too... and every other method as well...
%
 
so, as long as the DAOBusinessObject object lives the Connection is there... how am 
I supposed to close it, since every query needs it? Now I see, I should have a method 
to close the used conn or something... but we have up to 50 DAO* classes and more then 
200 JSPs... 
 
I agree with what u said about the finalize()... but what should I do then?
 
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 21/08/02 16:37 


On Wed, 21 Aug 2002, Christian J. Dechery wrote:

 Date: Wed, 21 Aug 2002 16:13:23 -0300
 From: Christian J. Dechery [EMAIL PROTECTED]
 Reply-To: Tomcat Users List [EMAIL PROTECTED]
 To: [EMAIL PROTECTED] 
 Subject: Re: problems with Connections

 I don't think it is TOTALLY offtopic, since the problem occurs within
 Tomcat...

From your description of the problem and your design approach, I'll bet it
would happen to you in a long-running non-servlet application as well.

and when I close tomcat all the connections and cursors are
 released...


Exactly what you'd expect if your application is leaking open connections,
statements, or result sets.

 as I said in my email I close ALL ResultSets and Statements in finally
 blocks...


Fine, I'll take your word for it ... but missing a case would easily
account for what you are seeing.  (In the particular case of Oracle, a
cursor is allocated for each result set, which is not released until the
result set is closed).

 as for closing the Connection... can I use the finalize() in the DAO*
 classes to use the method that returns the Connection to the pool?? Cuz
 I can't see anywhere else where I'd be able to do that...


The right design pattern is to acquire a connection, do whatever
processing is required, and immediately release it.  For example:

  DataSource dataSource = ...;  // Acquire reference to connection pool
  Connection conn = null;
  try {
conn = dataSource.getConnection();
... perform SQL operations as necessary ...
conn.close(); // Return connection to the pool
conn = null;
  } catch (SQLException e) {
... deal with problems ...
  } finally {
if (conn != null) {
  try {
conn.close();  // Return to pool even if an exception occurred
  } catch (SQLException e) {
;
  }
  conn = null;
}
  }

Waiting for the finalize() method to clean up just occupies resources
needlessly until the garbage collector gets around to running -- this
by itself could easily exhaust your available connections in a busy
environment.  It also assumes that your JDBC driver's implementation of
the finalize() method knows that this Connection was stored in a pool.
That seems like a really shaky bet.

A primary goal of your designs should be to minimize the amount of time
that you have a database connection allocated to the processing of a
particular request -- connections are expensive to create, and there's
always an upper limit on how many your database will support.

 .:| Christian J. Dechery
 .:| FINEP - Depto. de Sistemas
 .:| [EMAIL PROTECTED] 
 .:| (21) 2555-0332

Craig


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]






using INCLUDE with crossContext

2002-08-09 Thread Christian J. Dechery

I'm trying to use the crossContext feature to include a file that is in a context 
(that I call /global/) in other contexts...
 
/global is is configured in server.xml with crossContext=true, but when I do 
%@include file=/global/includes/file.jsp%
it gives me an error message with file not found...
 
what is wrong?
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332




How do I achieve a nice level of debugging?

2002-07-16 Thread Christian J. Dechery

I would like my tomcat (local, on my machine, for development) to have a nice level of 
debug. Just like the one that comes with JBuilder... it gives me information like this:
 
2002-07-16 10:51:13 - JspEngine -- /seta_sessao.jsp
2002-07-16 10:51:13 -   ServletPath: /seta_sessao.jsp
2002-07-16 10:51:13 -  PathInfo: null
2002-07-16 10:51:13 -  RealPath: C:\Contratacao\contratacao\seta_sessao.jsp
2002-07-16 10:51:13 -RequestURI: /contratacao/seta_sessao.jsp
2002-07-16 10:51:13 -   QueryString: null
2002-07-16 10:51:13 -Request Params: 
 
and prints exceptions... I couldn't get my tomcat to print exceptions generated by 
servlets... I have to see the log...
 
 
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332




RE: How do I achieve a nice level of debugging?

2002-07-16 Thread Christian J. Dechery

but I don't want it to to the logfile... I want it in the tomcat output... and can u 
give me examples of the settings on server.xml??
 
thanks
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 16/07/02 12:28  
use the RequestDumperValve. it provides a nice level of 
debuggings, at least concerning incoming requests. if you 
have a busy server, watch the log file size, though. 

benjamin vandgrift 
ekos project team 
ph#: 502.564.9375x242 
mob: 859.333.7320 



 -Original Message- 
 From: Christian J. Dechery [ mailto:[EMAIL PROTECTED]] 
 Sent: Tuesday, July 16, 2002 10:59 AM 
 To: [EMAIL PROTECTED] 
 Subject: How do I achieve a nice level of debugging? 
 
 
 I would like my tomcat (local, on my machine, for 
 development) to have a nice level of debug. Just like the one 
 that comes with JBuilder... it gives me information like this: 
 
 2002-07-16 10:51:13 - JspEngine -- /seta_sessao.jsp 
 2002-07-16 10:51:13 - ServletPath: /seta_sessao.jsp 
 2002-07-16 10:51:13 - PathInfo: null 
 2002-07-16 10:51:13 - RealPath: 
 C:\Contratacao\contratacao\seta_sessao.jsp 
 2002-07-16 10:51:13 - RequestURI: /contratacao/seta_sessao.jsp 
 2002-07-16 10:51:13 - QueryString: null 
 2002-07-16 10:51:13 - Request Params: 
 
 and prints exceptions... I couldn't get my tomcat to print 
 exceptions generated by servlets... I have to see the log... 
 
 
 
 .:| Christian J. Dechery 
 .:| FINEP - Depto. de Sistemas 
 .:| [EMAIL PROTECTED] 
 .:| (21) 2555-0332 
 
 

-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]  
For additional commands, e-mail:  mailto:[EMAIL PROTECTED]  






debug messages in 4 poorer than 3

2002-07-16 Thread Christian J. Dechery

I develop with JBuilder here and it comes with pre-configures tomcats. It has both 3.2 
and 4.0.1. The default is 3.2... and it works fine... but on our production 
environment we use 4.0.1... so I'd like to use it with JBuilder instead.
 
I already done it, quite easily... but I noticed that now the messages (on the server 
output window) are much worse... they are good for nothing 3.2 gives me a lot of 
usefull info and it colorizes the errors and exceptions... 4.0.1 has only useless 
info...
 
does anyone know how can I get the same kind of messages in 4.0.1 as in 3.2
 
thanks
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332




Environment vars in web.xml

2002-07-12 Thread Christian J. Dechery

I'm using Environment vars in my server.xml like this
 
Context path=/fapteste docBase=fapteste reloadable=true debug=0 
privileged=true
Environment name=ctxName type=java.lang.String value=fapteste/
/Context

but in JBuilder the config it creates to run Tomcat doesn't have any server.xml, only 
web.xml... and I tried setting an env-entry there but it didn't work... I was unable 
to fetch it with InitialContext.lookup() method...
 
can someone explain me this...
 
thanks
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332




Re: Big problem 2, the Mission!

2002-07-11 Thread Christian J. Dechery

YYYE!!! It worked... exaclty the way I wanted. Perfect..
 
Thanks a lot!
 
But now I have another problem, which I had before this one that I just skipped... 
this may be simpler for you guys to solve...
 
I need to place my classes (unpackaged) in \common\classes AND the oracle driver 
(packaged or unpackaged) in \common\classes or \common\lib... but that doesn't seem to 
work... altough my classes are found troughout all webapps, the oracle driver is not...
 
why??
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 10/07/02 17:22  
Hi, 

Let me see if I understand your problem. You have a JSP that creates 
business objects, the business object internally used some DAO objects, 
each DAO object when it performs it's processing calls DAO.getConnection 
(this happens to take some parameters which I assume are hardwired into 
DAOMain). 

Because you have a lot of JSP's your easiest (but not the simplest!) 
solution is to use JNDI. You could use parameters but then you would have to 
modify every single JSP. 

To each context add an environment entry of the following type: 
Context ... 
.. 
Environment name=db.url type=java.lang.String 
value=jdbc:postgres://localhost/mydb / 
/Context 

To read this value you need code of the following form (courtesy Will 
Hartung), you can add it anywhere, in your DAOMain, business object, etc. 
You probably want to add it to the function that initialises your database 
parameters. 

import javax.naming.*; 

InitialContext ctx = new InitialContext(); 
String dbUrl= (String)ctx.lookup(java:comp/env/db.url); 

I have tested this Tomcat 4.1.7. 

Regards. 

- Original Message - 
From: Christian J. Dechery  [EMAIL PROTECTED]  
To:  [EMAIL PROTECTED]  
Sent: Wednesday, July 10, 2002 8:16 PM 
Subject: Big problem 2, the Mission! 


First I would like to thank all of you for ur patience with me... 

my problem is I HATE reading documentation and references. I'm a 
trial-and-error developer... sometimes that's good, and sometimes (like 
today) it is not. 

I will now try to explain my problem with some code to be sure I won't get 
missunderstood. 

But before anything... I don't have ANY Servlets here... I was totally 
tripping... I tought a Servlet was the solution, but it is not. 

I only have JSPs (which I know are Servlets) and Beans. 

let's go: 

I have a webapp with lots of JSPs and classes... in my JSPs I have something 
like this: 
%@page import=SomeBusinessObject% 

% 
SomeBusinessObject sbo = new SomeBusinessObject(); 
sbo.setParameters( request.getParameter(id1), 
request.getParameter(id2) ); 

sbo.getSomeAttribute(); 
sbo.setSomeAttribute(); 
sbo.update(); sbo.delete()... etc.. etc... 

... lots of other code... 
% 

this SomeBusinessObject will have a reference to a DAOSomeBusinessObject 
where all the queries (insert, delete, update, select) resides... and that 
setParameters() method is only for it to know which row of the database 
we're handling with, the parameters match with the table keys of course. But 
that is irrelevant here. 
I have also a class called DAO which provides all of the other DAO*s with a 
Connection... this is done internally within each DAO*. 

the method bellow is in DAO, which all the other DAO*s call to get the 
Connection. 

public static synchronized Connection getConnection(String usr, String pwd, 
String url, String driver) { 
Connection con = null; 

// some code here to make some checks... irrelevant 

try { 
Class.forName( driver ); 
con = DriverManager.getConnection(url, usr, pwd); 
} catch(ClassNotFoundException cnf) { 
System.out.println (*** Erro: driver nao encontrado! 
+cnf.getMessage()); 
} catch(SQLException sql) { 
String detalhes = URL = +url+\nUSER = +usr+\nPWD = +pwd; 
System.out.println(*** Erro ao obter conexão! 
+sql.getMessage()+\n+detalhes ); 
} 

// a little bit more code 

return con; 
} 

now the problem - I'll try to be very clear (my english SUX, please be 
patient with me). 

the webapp points to a specific db URL... this URL is in the DAOMain... if I 
want to change the db, I'll have to change DAOMain, recompile it, and 
overwrite it... nothing weird so far. Right? 

The big thing is: this webapp gets replicated... so I copy the ENTIRE dir... 
classes, JSPs, jars... everything... and I know how stupid this is... and 
that's the problem... 

- in each of these webapps, the only thing that changes is the JSPs, and 
maybe the DB url... 

WHAT I WANT IS: I want to put our classes, jars and the oracle driver in the 
$TOMCAT_HOME\common dir, because they don't change from one webapp to 
another BUT since DAOMain holds the URL this is not possible (each 
webapp must have its own DAOMain)... I wanna create a CLASS that will 
receive a request from DAO or DAOMain (residing in \common) and provide a 
Connection based on the Context of the JSP that used SomeBusinessObject - 
DAOSomeBusinessObject

Why doesn't my classes see the oracle driver?

2002-07-11 Thread Christian J. Dechery

I had a webapp working ok... 
 
I had it set like this:
$TOMCAT_HOME\webapps\fap\WEB-INF\classes\[ all my classes unpackaged here]
$TOMCAT_HOME\webapps\fap\WEB-INF\lib\classes12.jar -- this is the Oracle Driver
 
now I want this:
$TOMCAT_HOME\common\classes\[all my classes unpackaged here]
$TOMCAT_HOME\common\lib\classes12.jar -OR- $TOMCAT_HOME\common\classes\[oracle driver 
unpackaged]
 
why can't this work??? When a JSP accessing one of my classes, the class is found but 
it gives me an error saying it didn't find the oracle drivers...
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332




Re: Why doesn't my classes see the oracle driver?

2002-07-11 Thread Christian J. Dechery

Yes I did... but that's not the point... I've even tried unpacking it... it doesn't 
work... 
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 11/07/02 12:33  
Did you rename the file to classes12.jar from the original 
classes12.zip? 

I know there were some issues with that some time ago... 

 [EMAIL PROTECTED] 07/11/02 09:10 AM  
I had a webapp working ok... 

I had it set like this: 
$TOMCAT_HOME\webapps\fap\WEB-INF\classes\[ all my classes unpackaged 
here] 
$TOMCAT_HOME\webapps\fap\WEB-INF\lib\classes12.jar -- this is the 
Oracle Driver 

now I want this: 
$TOMCAT_HOME\common\classes\[all my classes unpackaged here] 
$TOMCAT_HOME\common\lib\classes12.jar -OR- 
$TOMCAT_HOME\common\classes\[oracle driver unpackaged] 

why can't this work??? When a JSP accessing one of my classes, the class 
is found but it gives me an error saying it didn't find the oracle 
drivers... 


-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]  
For additional commands, e-mail:  mailto:[EMAIL PROTECTED]  






RE: Need Ideas... big problem! (long)

2002-07-10 Thread Christian J. Dechery

ok... but remember that all the classes will reside in the common\classes dir...
 
So how will the class know which context accessed it? That's what I can't figure 
out... I tought about config files... but I don't know inside the dispatcher class how 
to identify the context... or to read the proper config file...
 
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 09/07/02 17:24  

If you don't want to go the JNDI route, you could also do something like set 
init params in each application's web.xml file with the db connection info or 
create a .properties file for each application and read in the db connection 
info from that. 

HTH, 
-Jeff 




Kranson, Bob 
Bob_Kranson@comp To: 'Tomcat Users List'  [EMAIL PROTECTED]  
uware.com cc: 
Subject: RE: Need Ideas... big problem! (long) 
07/09/02 02:41 PM 
Please respond to 
Tomcat Users 
List 






Why don't you store the JDBC URL in JNDI and have DAO look it up 
dynamically 

Bob Kranson 
Software Technical Support Analyst 
UNIFACE and Optimal Products Technical Support 
U.S. Support Center 888-551-0404 
New Calls: [EMAIL PROTECTED] 
31440 Northwestern Hwy, Farmington Hills, MI 48334-2564 
(248)737-7300 x12702 Fax:(248)737-7574 


 -Original Message- 
 From: Christian J. Dechery [ mailto:[EMAIL PROTECTED]] 
 Sent: Tuesday, July 09, 2002 2:38 PM 
 To: [EMAIL PROTECTED] 
 Subject: Need Ideas... big problem! (long) 
 
 
 I have a huge problem here... and I can't think of a simple 
 solution for it, I'm hoping u guys can give some light. :) 
 
 Let me first describe the environment here, then the problem. 
 
 We have here a webapp called FAP (c:\tomcat\fap). It is 
 composed of: /fap/*.jsp (like a hundred of them) 
 /fap/WEB-INF/classes/finep (this package finep has a lot of 
 subpackages) /fap/WEB-INF/classes/finep/DAO.class -- here 
 the problem resides... /fab/lib/OracleDrivers.jar 
 
 the class DAO provides the Connection to an Oracle database... 
 
 so far, everything is fine... but here's the thing... this 
 webapp gets replicated... the whole dir, because there are 
 other instances of this system with small changes, and we 
 didn't have the time to create a self-configuring app to 
 allow that... so we copy the whole dir and make the necessary 
 changes... BUT... the classes never change... only the 
 JSPs... AND another thing that may change is the database 
 (and of course DAO)... so how it is done? 
 
 we have /fap with DAO.class pointing to a specific db URL 
 and; we have (for example) /fap2 with a few JSPs changes and 
 DAO.class pointing to another URL. 
 
 this of course sux! If we wanna change the database of a 
 specific webapp we have to re-compile DAO and place it 
 there... and if we change a class (any class) we have to 
 update it in ALL the contexts... 
 
 What I want: 
 I would like to place the package finep and the 
 OracleDrivers in the global context 
 (c:\tomcat\common\classes, \lib), so all would be pretty and 
 centralized; and create something like a Connection 
 Dispatcher (also in the global context) that would receive 
 requests from the JSPs and provide a Connection to the 
 specific URL based in which context that JSP was when the 
 request was made. I don't know if that's possible... I'm just 
 guessing... of course I want do this as painless as 
 possible... cuz we have like 80 classes and more than 150 JSPs... 
 
 to confuse??? My english also sux... sorry! 
 
 
 .:| Christian J. Dechery 
 .:| FINEP - Depto. de Sistemas 
 .:| [EMAIL PROTECTED] 
 .:| (21) 2555-0332 
 
 



The contents of this e-mail are intended for the named addressee only. It 
contains information that may be confidential. Unless you are the named 
addressee or an authorized designee, you may not copy or use it, or disclose 
it to anyone else. If you received it in error please notify us immediately 
and then destroy it. 


-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]  
For additional commands, e-mail:  mailto:[EMAIL PROTECTED]  






-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]  
For additional commands, e-mail:  mailto:[EMAIL PROTECTED]  






Re: Need Ideas... big problem! (long)

2002-07-10 Thread Christian J. Dechery

well... first one thing... the class that provides the connection (DAO) is not a 
Servlet... would I have to make a Servlet (the mentioned Connection Dispatcher) in 
order for that to work???
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 09/07/02 17:41  
Or even simpler why not store it as a parameter in the server.xml. You will 
need to add the parameter to each of your contexts in the server.xml as 
follows:- 

Context path=/examples docBase=examples  
.. 
Parameter name=db.url value=jdbc:postgres://localhost/mydb 
override=false/ 
/Context 

And then in your servlet code you use the following to retrieve it (from 
your servlet):- 

getServletContext().getInitParameter(db.url) 

Regards. 
- Original Message - 
From: Christian J. Dechery  [EMAIL PROTECTED]  
To:  [EMAIL PROTECTED]  
Sent: Tuesday, July 09, 2002 8:47 PM 
Subject: RE: Need Ideas... big problem! (long) 


Sorry... but could u explain this a little furhter? I'm not familiar with 
JNDI. 

thanks 

.:| Christian J. Dechery 
.:| FINEP - Depto. de Sistemas 
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332 

 [EMAIL PROTECTED] 09/07/02 16:41  
Why don't you store the JDBC URL in JNDI and have DAO look it up 
dynamically 

Bob Kranson 
Software Technical Support Analyst 
UNIFACE and Optimal Products Technical Support 
U.S. Support Center 888-551-0404 
New Calls: [EMAIL PROTECTED] 
31440 Northwestern Hwy, Farmington Hills, MI 48334-2564 
(248)737-7300 x12702 Fax:(248)737-7574 


 -Original Message- 
 From: Christian J. Dechery [ mailto:[EMAIL PROTECTED]] 
 Sent: Tuesday, July 09, 2002 2:38 PM 
 To: [EMAIL PROTECTED] 
 Subject: Need Ideas... big problem! (long) 
 
 
 I have a huge problem here... and I can't think of a simple 
 solution for it, I'm hoping u guys can give some light. :) 
 
 Let me first describe the environment here, then the problem. 
 
 We have here a webapp called FAP (c:\tomcat\fap). It is 
 composed of: /fap/*.jsp (like a hundred of them) 
 /fap/WEB-INF/classes/finep (this package finep has a lot of 
 subpackages) /fap/WEB-INF/classes/finep/DAO.class -- here 
 the problem resides... /fab/lib/OracleDrivers.jar 
 
 the class DAO provides the Connection to an Oracle database... 
 
 so far, everything is fine... but here's the thing... this 
 webapp gets replicated... the whole dir, because there are 
 other instances of this system with small changes, and we 
 didn't have the time to create a self-configuring app to 
 allow that... so we copy the whole dir and make the necessary 
 changes... BUT... the classes never change... only the 
 JSPs... AND another thing that may change is the database 
 (and of course DAO)... so how it is done? 
 
 we have /fap with DAO.class pointing to a specific db URL 
 and; we have (for example) /fap2 with a few JSPs changes and 
 DAO.class pointing to another URL. 
 
 this of course sux! If we wanna change the database of a 
 specific webapp we have to re-compile DAO and place it 
 there... and if we change a class (any class) we have to 
 update it in ALL the contexts... 
 
 What I want: 
 I would like to place the package finep and the 
 OracleDrivers in the global context 
 (c:\tomcat\common\classes, \lib), so all would be pretty and 
 centralized; and create something like a Connection 
 Dispatcher (also in the global context) that would receive 
 requests from the JSPs and provide a Connection to the 
 specific URL based in which context that JSP was when the 
 request was made. I don't know if that's possible... I'm just 
 guessing... of course I want do this as painless as 
 possible... cuz we have like 80 classes and more than 150 JSPs... 
 
 to confuse??? My english also sux... sorry! 
 
 
 .:| Christian J. Dechery 
 .:| FINEP - Depto. de Sistemas 
 .:| [EMAIL PROTECTED] 
 .:| (21) 2555-0332 
 
 



The contents of this e-mail are intended for the named addressee only. It 
contains information that may be confidential. Unless you are the named 
addressee or an authorized designee, you may not copy or use it, or disclose 
it to anyone else. If you received it in error please notify us immediately 
and then destroy it. 


-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED] 
 
For additional commands, e-mail:  
mailto:[EMAIL PROTECTED]  






-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]  
For additional commands, e-mail:  mailto:[EMAIL PROTECTED]  






can't get class to be accessed globally

2002-07-10 Thread Christian J. Dechery

I have a class (let's name her A)... and I want it to be accessed by all webapps...
 
so I tried placing her at tomcat_home\classes, tomcat_home\common\classes... but when 
I execute the JSP it says :
Generated servlet error:
C:\Tomcat 4\work\localhost\teste1\teste$jsp.java:59: Class org.apache.jsp.A not found.
 A tcd = new A();
 
here is the code of the JSP:
@page import=A
 
%
 A tcd = new A();
 out.println(A URL para esse contexto é \+tcd.myContextURL()+\.);
%
 
why is this happening?
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332




Re: Need Ideas... big problem! (long)

2002-07-10 Thread Christian J. Dechery

didn't work... I did a test here to see if this thing worked before implementing the 
Connection Dispatcher...
the Servlet can't find the context in which the JSP that called it is...
 
here's what I did:
 
* created two classes TesteDispatcher and TesteCallDispatcher. 
TesteDispatcher is the Servlet, and TesteCallDispatcher is just a dummy class to make 
a call to this servlet...
 
* I then placed both classes in $tomcat_home\common\classes
 
* created a context called \teste1
 Context path=/teste1 docBase=teste1 debug=0 reloadable=true
 Parameter name=url value=URL do Contexto teste1 override=false/
 /Context

* created a JSP called teste.jsp
%@page import=dispatch.TesteCallDispatcher%
 
%
 TesteCallDispatcher tcd = new TesteCallDispatcher();
 out.println(A URL para esse contexto é \+tcd.myContextURL()+\.);
%
 
when I execute it, nothing happens... there is a call in TesteDispatcher like this:
ServletConfig sConf = getServletConfig(); -- this is returning NULL
 
what did I do wrong? Or was it that I missunderstood ur solution, or even, u 
missunderstood my problem. :)
 
thanks
 
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 09/07/02 17:41  
Or even simpler why not store it as a parameter in the server.xml. You will 
need to add the parameter to each of your contexts in the server.xml as 
follows:- 

Context path=/examples docBase=examples  
.. 
Parameter name=db.url value=jdbc:postgres://localhost/mydb 
override=false/ 
/Context 

And then in your servlet code you use the following to retrieve it (from 
your servlet):- 

getServletContext().getInitParameter(db.url) 

Regards. 
- Original Message - 
From: Christian J. Dechery  [EMAIL PROTECTED]  
To:  [EMAIL PROTECTED]  
Sent: Tuesday, July 09, 2002 8:47 PM 
Subject: RE: Need Ideas... big problem! (long) 


Sorry... but could u explain this a little furhter? I'm not familiar with 
JNDI. 

thanks 

.:| Christian J. Dechery 
.:| FINEP - Depto. de Sistemas 
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332 

 [EMAIL PROTECTED] 09/07/02 16:41  
Why don't you store the JDBC URL in JNDI and have DAO look it up 
dynamically 

Bob Kranson 
Software Technical Support Analyst 
UNIFACE and Optimal Products Technical Support 
U.S. Support Center 888-551-0404 
New Calls: [EMAIL PROTECTED] 
31440 Northwestern Hwy, Farmington Hills, MI 48334-2564 
(248)737-7300 x12702 Fax:(248)737-7574 


 -Original Message- 
 From: Christian J. Dechery [ mailto:[EMAIL PROTECTED]] 
 Sent: Tuesday, July 09, 2002 2:38 PM 
 To: [EMAIL PROTECTED] 
 Subject: Need Ideas... big problem! (long) 
 
 
 I have a huge problem here... and I can't think of a simple 
 solution for it, I'm hoping u guys can give some light. :) 
 
 Let me first describe the environment here, then the problem. 
 
 We have here a webapp called FAP (c:\tomcat\fap). It is 
 composed of: /fap/*.jsp (like a hundred of them) 
 /fap/WEB-INF/classes/finep (this package finep has a lot of 
 subpackages) /fap/WEB-INF/classes/finep/DAO.class -- here 
 the problem resides... /fab/lib/OracleDrivers.jar 
 
 the class DAO provides the Connection to an Oracle database... 
 
 so far, everything is fine... but here's the thing... this 
 webapp gets replicated... the whole dir, because there are 
 other instances of this system with small changes, and we 
 didn't have the time to create a self-configuring app to 
 allow that... so we copy the whole dir and make the necessary 
 changes... BUT... the classes never change... only the 
 JSPs... AND another thing that may change is the database 
 (and of course DAO)... so how it is done? 
 
 we have /fap with DAO.class pointing to a specific db URL 
 and; we have (for example) /fap2 with a few JSPs changes and 
 DAO.class pointing to another URL. 
 
 this of course sux! If we wanna change the database of a 
 specific webapp we have to re-compile DAO and place it 
 there... and if we change a class (any class) we have to 
 update it in ALL the contexts... 
 
 What I want: 
 I would like to place the package finep and the 
 OracleDrivers in the global context 
 (c:\tomcat\common\classes, \lib), so all would be pretty and 
 centralized; and create something like a Connection 
 Dispatcher (also in the global context) that would receive 
 requests from the JSPs and provide a Connection to the 
 specific URL based in which context that JSP was when the 
 request was made. I don't know if that's possible... I'm just 
 guessing... of course I want do this as painless as 
 possible... cuz we have like 80 classes and more than 150 JSPs... 
 
 to confuse??? My english also sux... sorry! 
 
 
 .:| Christian J. Dechery 
 .:| FINEP - Depto. de Sistemas 
 .:| [EMAIL PROTECTED] 
 .:| (21) 2555-0332 
 
 



The contents of this e-mail are intended for the named addressee only. It 
contains information that may be confidential. Unless you are the named 
addressee or an authorized designee, you may not copy

Re: Need Ideas... big problem! (long)

2002-07-10 Thread Christian J. Dechery

I'm having some difficulty understanding the solution u guys provided me... maybe I 
explained my problem badly, so u aren't fully understanding it... 

but I have a question that is quite simple: 
Is it possible for a class (or Servlet) located in $tomcat_home\common\classes - that 
will be accessed from all webapps - to know from which context a JSP/Servlet called 
it? 

for example... I have a class A in common\classes and it has a method doSomething()... 
say I have a JSP $tomcat_home\webapps\test\1.jsp that looks something like: 

%@page import=A% 
% 
String x = A.doSomething(); 
% 

so... would it be possible for A to know that when doSomething() was called, the 
context was test?

 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 10/07/02 12:12  
A JSP is a servlet, so you shouldn't need to create another class derived 
from servlet to do the job. 

If your call is directly to a servlet, that servlet can use the code for 
parameter lookup itself as is. 

Regards. 
- Original Message - 
From: Christian J. Dechery  [EMAIL PROTECTED]  
To:  [EMAIL PROTECTED]  
Sent: Wednesday, July 10, 2002 2:33 PM 
Subject: Re: Need Ideas... big problem! (long) 


didn't work... I did a test here to see if this thing worked before 
implementing the Connection Dispatcher... 
the Servlet can't find the context in which the JSP that called it is... 

here's what I did: 

* created two classes TesteDispatcher and TesteCallDispatcher. 
TesteDispatcher is the Servlet, and TesteCallDispatcher is just a dummy 
class to make a call to this servlet... 

* I then placed both classes in $tomcat_home\common\classes 

* created a context called \teste1 
Context path=/teste1 docBase=teste1 debug=0 reloadable=true 
Parameter name=url value=URL do Contexto teste1 override=false/ 
/Context 

* created a JSP called teste.jsp 
%@page import=dispatch.TesteCallDispatcher% 

% 
TesteCallDispatcher tcd = new TesteCallDispatcher(); 
out.println(A URL para esse contexto é \+tcd.myContextURL()+\.); 
% 

when I execute it, nothing happens... there is a call in TesteDispatcher 
like this: 
ServletConfig sConf = getServletConfig(); -- this is returning NULL 

what did I do wrong? Or was it that I missunderstood ur solution, or even, u 
missunderstood my problem. :) 

thanks 


.:| Christian J. Dechery 
.:| FINEP - Depto. de Sistemas 
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332 

 [EMAIL PROTECTED] 09/07/02 17:41  
Or even simpler why not store it as a parameter in the server.xml. You will 
need to add the parameter to each of your contexts in the server.xml as 
follows:- 

Context path=/examples docBase=examples  
.. 
Parameter name=db.url value=jdbc:postgres://localhost/mydb 
override=false/ 
/Context 

And then in your servlet code you use the following to retrieve it (from 
your servlet):- 

getServletContext().getInitParameter(db.url) 

Regards. 
- Original Message - 
From: Christian J. Dechery  [EMAIL PROTECTED]  
To:  [EMAIL PROTECTED]  
Sent: Tuesday, July 09, 2002 8:47 PM 
Subject: RE: Need Ideas... big problem! (long) 


Sorry... but could u explain this a little furhter? I'm not familiar with 
JNDI. 

thanks 

.:| Christian J. Dechery 
.:| FINEP - Depto. de Sistemas 
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332 

 [EMAIL PROTECTED] 09/07/02 16:41  
Why don't you store the JDBC URL in JNDI and have DAO look it up 
dynamically 

Bob Kranson 
Software Technical Support Analyst 
UNIFACE and Optimal Products Technical Support 
U.S. Support Center 888-551-0404 
New Calls: [EMAIL PROTECTED] 
31440 Northwestern Hwy, Farmington Hills, MI 48334-2564 
(248)737-7300 x12702 Fax:(248)737-7574 


 -Original Message- 
 From: Christian J. Dechery [ mailto:[EMAIL PROTECTED]] 
 Sent: Tuesday, July 09, 2002 2:38 PM 
 To: [EMAIL PROTECTED] 
 Subject: Need Ideas... big problem! (long) 
 
 
 I have a huge problem here... and I can't think of a simple 
 solution for it, I'm hoping u guys can give some light. :) 
 
 Let me first describe the environment here, then the problem. 
 
 We have here a webapp called FAP (c:\tomcat\fap). It is 
 composed of: /fap/*.jsp (like a hundred of them) 
 /fap/WEB-INF/classes/finep (this package finep has a lot of 
 subpackages) /fap/WEB-INF/classes/finep/DAO.class -- here 
 the problem resides... /fab/lib/OracleDrivers.jar 
 
 the class DAO provides the Connection to an Oracle database... 
 
 so far, everything is fine... but here's the thing... this 
 webapp gets replicated... the whole dir, because there are 
 other instances of this system with small changes, and we 
 didn't have the time to create a self-configuring app to 
 allow that... so we copy the whole dir and make the necessary 
 changes... BUT... the classes never change... only the 
 JSPs... AND another thing that may change is the database 
 (and of course DAO)... so how it is done? 
 
 we have /fap with DAO.class pointing to a specific db URL 
 and; we

Re: Need Ideas... big problem! (long)

2002-07-10 Thread Christian J. Dechery

But I want the code I would write in the A class... cuz I will create a Servlet to 
provide a connection to the JSPs, but I don't wanna change the JSPs... inside my 
Servlet (A) I don't have access to the request object.
 
Could u write some example code for the A class to figure in which context the method 
doSomething() was called?
 
Thanks...
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 10/07/02 13:51  


On Wed, 10 Jul 2002, Christian J. Dechery wrote: 

 Date: Wed, 10 Jul 2002 13:27:26 -0300 
 From: Christian J. Dechery  [EMAIL PROTECTED]  
 Reply-To: Tomcat Users List  [EMAIL PROTECTED]  
 To: [EMAIL PROTECTED] 
 Subject: Re: Need Ideas... big problem! (long) 
 
 I'm having some difficulty understanding the solution u guys provided me... maybe I 
explained my problem badly, so u aren't fully understanding it... 
 
 but I have a question that is quite simple: Is it possible for a class 
 (or Servlet) located in $tomcat_home\common\classes - that will be 
 accessed from all webapps - to know from which context a JSP/Servlet 
 called it? 
 
 for example... I have a class A in common\classes and it has a method 
doSomething()... say I have a JSP $tomcat_home\webapps\test\1.jsp that looks 
something like: 
 
 %@page import=A% 
 % 
 String x = A.doSomething(); 
 % 
 
 so... would it be possible for A to know that when doSomething() was 
 called, the context was test? 
 

Sure ... that's really easy. You've got at least the following options: 

* Call request.getContextPath() and you'll get the context path of the 
web application that is responding to this request. 

* The application object in a JSP page is in fact the ServletContext 
for the current webapp, so you can call things like 

% 
Properties props = new Properties(); 
InputStream stream = 
application.getResourceAsStream(/WEB-INF/myprops.properties); 
props.load(stream); 
stream.close(); 
% 

to load a properties file from inside the WEB-INF subdirectory of your web 
application. 

As a general note, however, you should really be doing this sort of thing 
in startup code of a servlet, which stashes the results as servlet context 
parameters for everyone else to use. Using scriptlets to mix functional 
logic into your JSP pages is going to cause you maintenance nightmares 
over time. 

Craig 


-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]  
For additional commands, e-mail:  mailto:[EMAIL PROTECTED]  






Re: Need Ideas... big problem! (long)

2002-07-10 Thread Christian J. Dechery

exaclty... I looked on HttpServlet... request and response are passed as parameters... 
so I don't HAVE it. And since it's passed as a parameter I would have to change 150 
JSPs to pass this new parameter...
 
and I don't wanna change anything, only create a new class... if in the solution comes 
changing all the JSPs and classes I'm sure that's not the best one... I may have asked 
the wrong question... let's say:
 
public class TesteDispatcher extends HttpServlet {
private static final String CONTENT_TYPE = text/html;
 
 //Initialize global variables
public void init() throws ServletException {
}
 
 //Clean up resources
public void destroy() {
}
 
 public String doSomething() {
  // this is the method...
 }
}
 
Is there anyway doSomething() can know in which Context it was called? Remember that 
this class is in \common\classes.
 
thanks for ur patience
 
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 10/07/02 14:23  

Hi, Christian. 

I would recommend now taking a good look at the Java Servlet 
Specification and letting all these suggestions digest while you go through 
that. Things should start to make more sense once you have a better handle on 
servlets. Maybe take a look at the Tomcat servlet examples too. 

Your servlet should definitely have access to the request object, since 
if you look at the specs on HttpServlet, you'll see that it is passed as a 
parameter to its various methods. 

HTH, 
-Jeff 




Christian J. 
Dechery To:  [EMAIL PROTECTED]  
christian@fin cc: 
ep.gov.br Subject: Re: Need Ideas... big problem! (long) 

07/10/02 12:30 
PM 
Please respond 
to Tomcat 
Users List 






But I want the code I would write in the A class... cuz I will create a 
Servlet to provide a connection to the JSPs, but I don't wanna change the 
JSPs... inside my Servlet (A) I don't have access to the request object. 

Could u write some example code for the A class to figure in which context the 
method doSomething() was called? 

Thanks... 

.:| Christian J. Dechery 
.:| FINEP - Depto. de Sistemas 
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332 

 [EMAIL PROTECTED] 10/07/02 13:51  


On Wed, 10 Jul 2002, Christian J. Dechery wrote: 

 Date: Wed, 10 Jul 2002 13:27:26 -0300 
 From: Christian J. Dechery  [EMAIL PROTECTED]  
 Reply-To: Tomcat Users List  [EMAIL PROTECTED]  
 To: [EMAIL PROTECTED] 
 Subject: Re: Need Ideas... big problem! (long) 
 
 I'm having some difficulty understanding the solution u guys provided me... 
maybe I explained my problem badly, so u aren't fully understanding it... 
 
 but I have a question that is quite simple: Is it possible for a class 
 (or Servlet) located in $tomcat_home\common\classes - that will be 
 accessed from all webapps - to know from which context a JSP/Servlet 
 called it? 
 
 for example... I have a class A in common\classes and it has a method 
doSomething()... say I have a JSP $tomcat_home\webapps\test\1.jsp that looks 
something like: 
 
 %@page import=A% 
 % 
 String x = A.doSomething(); 
 % 
 
 so... would it be possible for A to know that when doSomething() was 
 called, the context was test? 
 

Sure ... that's really easy. You've got at least the following options: 

* Call request.getContextPath() and you'll get the context path of the 
web application that is responding to this request. 

* The application object in a JSP page is in fact the ServletContext 
for the current webapp, so you can call things like 

% 
Properties props = new Properties(); 
InputStream stream = 
application.getResourceAsStream(/WEB-INF/myprops.properties); 
props.load(stream); 
stream.close(); 
% 

to load a properties file from inside the WEB-INF subdirectory of your web 
application. 

As a general note, however, you should really be doing this sort of thing 
in startup code of a servlet, which stashes the results as servlet context 
parameters for everyone else to use. Using scriptlets to mix functional 
logic into your JSP pages is going to cause you maintenance nightmares 
over time. 

Craig 


-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]  
For additional commands, e-mail:  mailto:[EMAIL PROTECTED] 
 








-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]  
For additional commands, e-mail:  mailto:[EMAIL PROTECTED]  






RE: Need Ideas... big problem! (long)

2002-07-10 Thread Christian J. Dechery

But that's exactly what I'm talking about... 
if doSomething() has to receive parameters, then the answer to my question (like 10 
posts ago) is NO - there is no WAY a class/Servlet can know in which context its 
method was called. This can only be done if the something is passed to this class: the 
Context itself or the Request and Response objects... right?
 
I know little of the Servlet spec, but my question was so simple... I guess I didn't 
make myself clear.
 
Sorry to bother you all... I now know that my problem has no solution. :((
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 10/07/02 14:50  

Please, check some docs and some servlet examples. 

You most certainly DO HAVE both the Response object and the Request object 
EVERY TIME your servlet is called. That's just how it works. Whether you 
choose to use the objects in your class's methods is up to you. Just 
because you don't choose to use them doesn't mean they aren't there. 

For example, a servlet extends HttpServlet. Here is the HttpServlet spec, 
right from the source: 
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServlet 
.html 

Please note how the methods are called. 

So, what you REALLY need to do, in your code, is not doSomething() {}, but 
doSomething(HttpServletRequest req, HttpServletResponse resp) {}. 

Check the docs! 

John Turner 
[EMAIL PROTECTED] 


-Original Message- 
From: Christian J. Dechery [ mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, July 10, 2002 1:32 PM 
To: [EMAIL PROTECTED] 
Subject: Re: Need Ideas... big problem! (long) 


exaclty... I looked on HttpServlet... request and response are passed as 
parameters... so I don't HAVE it. And since it's passed as a parameter I 
would have to change 150 JSPs to pass this new parameter... 

and I don't wanna change anything, only create a new class... if in the 
solution comes changing all the JSPs and classes I'm sure that's not the 
best one... I may have asked the wrong question... let's say: 

public class TesteDispatcher extends HttpServlet { 
private static final String CONTENT_TYPE = text/html; 

//Initialize global variables 
public void init() throws ServletException { 
} 

//Clean up resources 
public void destroy() { 
} 

public String doSomething() { 
// this is the method... 
} 
} 

Is there anyway doSomething() can know in which Context it was called? 
Remember that this class is in \common\classes. 

thanks for ur patience 


.:| Christian J. Dechery 
.:| FINEP - Depto. de Sistemas 
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332 

 [EMAIL PROTECTED] 10/07/02 14:23  

Hi, Christian. 

I would recommend now taking a good look at the Java Servlet 
Specification and letting all these suggestions digest while you go through 
that. Things should start to make more sense once you have a better handle 
on 
servlets. Maybe take a look at the Tomcat servlet examples too. 

Your servlet should definitely have access to the request object, since 
if you look at the specs on HttpServlet, you'll see that it is passed as a 
parameter to its various methods. 

HTH, 
-Jeff 




Christian J. 
Dechery To:  [EMAIL PROTECTED]  
christian@fin cc: 
ep.gov.br Subject: Re: Need Ideas... big problem! (long) 

07/10/02 12:30 
PM 
Please respond 
to Tomcat 
Users List 






But I want the code I would write in the A class... cuz I will create a 
Servlet to provide a connection to the JSPs, but I don't wanna change the 
JSPs... inside my Servlet (A) I don't have access to the request object. 

Could u write some example code for the A class to figure in which context 
the 
method doSomething() was called? 

Thanks... 

.:| Christian J. Dechery 
.:| FINEP - Depto. de Sistemas 
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332 

 [EMAIL PROTECTED] 10/07/02 13:51  


On Wed, 10 Jul 2002, Christian J. Dechery wrote: 

 Date: Wed, 10 Jul 2002 13:27:26 -0300 
 From: Christian J. Dechery  [EMAIL PROTECTED]  
 Reply-To: Tomcat Users List  [EMAIL PROTECTED]  
 To: [EMAIL PROTECTED] 
 Subject: Re: Need Ideas... big problem! (long) 
 
 I'm having some difficulty understanding the solution u guys provided 
me... 
maybe I explained my problem badly, so u aren't fully understanding it... 
 
 but I have a question that is quite simple: Is it possible for a class 
 (or Servlet) located in $tomcat_home\common\classes - that will be 
 accessed from all webapps - to know from which context a JSP/Servlet 
 called it? 
 
 for example... I have a class A in common\classes and it has a method 
doSomething()... say I have a JSP $tomcat_home\webapps\test\1.jsp that looks 

something like: 
 
 %@page import=A% 
 % 
 String x = A.doSomething(); 
 % 
 
 so... would it be possible for A to know that when doSomething() was 
 called, the context was test? 
 

Sure ... that's really easy. You've got at least the following options: 

* Call request.getContextPath() and you'll get the context path of the 
web application

Big problem 2, the Mission!

2002-07-10 Thread Christian J. Dechery

First I would like to thank all of you for ur patience with me... 

my problem is I HATE reading documentation and references. I'm a trial-and-error 
developer... sometimes that's good, and sometimes (like today) it is not. 

I will now try to explain my problem with some code to be sure I won't get 
missunderstood. 

But before anything... I don't have ANY Servlets here... I was totally tripping... I 
tought a Servlet was the solution, but it is not. 

I only have JSPs (which I know are Servlets) and Beans. 

let's go: 

I have a webapp with lots of JSPs and classes... in my JSPs I have something like 
this: 
%@page import=SomeBusinessObject% 

% 
SomeBusinessObject sbo = new SomeBusinessObject(); 
sbo.setParameters( request.getParameter(id1), request.getParameter(id2) ); 

sbo.getSomeAttribute(); 
sbo.setSomeAttribute(); 
sbo.update(); sbo.delete()... etc.. etc... 

... lots of other code... 
% 

this SomeBusinessObject will have a reference to a DAOSomeBusinessObject where all the 
queries (insert, delete, update, select) resides... and that setParameters() method is 
only for it to know which row of the database we're handling with, the parameters 
match with the table keys of course. But that is irrelevant here.
I have also a class called DAO which provides all of the other DAO*s with a 
Connection... this is done internally within each DAO*. 

the method bellow is in DAO, which all the other DAO*s call to get the Connection.
 
public static synchronized Connection getConnection(String usr, String pwd, String 
url, String driver) {
 Connection con  = null;
 
// some code here to make some checks... irrelevant
 
  try {
   Class.forName( driver );
  con = DriverManager.getConnection(url, usr, pwd);
 } catch(ClassNotFoundException cnf) {
  System.out.println (*** Erro: driver nao encontrado! +cnf.getMessage());
 } catch(SQLException sql) {
   String detalhes = URL = +url+\nUSER = +usr+\nPWD = +pwd;
  System.out.println(*** Erro ao obter conexão! +sql.getMessage()+\n+detalhes 
);
 }
 
// a little bit more code
 
  return con;
 }

now the problem - I'll try to be very clear (my english SUX, please be patient with 
me).
 
the webapp points to a specific db URL... this URL is in the DAOMain... if I want to 
change the db, I'll have to change DAOMain, recompile it, and overwrite it... nothing 
weird so far. Right?
 
The big thing is: this webapp gets replicated... so I copy the ENTIRE dir... classes, 
JSPs, jars... everything... and I know how stupid this is... and that's the problem...
 
- in each of these webapps, the only thing that changes is the JSPs, and maybe the DB 
url...
 
WHAT I WANT IS: I want to put our classes, jars and the oracle driver in the 
$TOMCAT_HOME\common dir, because they don't change from one webapp to another BUT 
since DAOMain holds the URL this is not possible (each webapp must have its own 
DAOMain)... I wanna create a CLASS that will receive a request from DAO or DAOMain 
(residing in \common) and provide a Connection based on the Context of the JSP that 
used SomeBusinessObject - DAOSomeBusinessObject - DAO.
 
or maybe DAO could do that... let's say I would write some code in getConnection() to 
find out where (Context) it is (well... actually DAO is always in the same place.. but 
the JSP that uses it, and calls it, is not) to provide the right Connection... BUT 
without ANY change of parameters to getConnection(), since that would snowball into a 
mega change of method's signatures that would end in the JSPs...
 
(I'm tired...)
 
well... that's it... I don't think I can be clearer than that... my english stops 
here... :)


 
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332




Need Ideas... big problem! (long)

2002-07-09 Thread Christian J. Dechery

I have a huge problem here... and I can't think of a simple solution for it, I'm 
hoping u guys can give some light. :)
 
Let me first describe the environment here, then the problem.
 
We have here a webapp called FAP (c:\tomcat\fap). It is composed of:
/fap/*.jsp (like a hundred of them)
/fap/WEB-INF/classes/finep (this package finep has a lot of subpackages)
/fap/WEB-INF/classes/finep/DAO.class -- here the problem resides...
/fab/lib/OracleDrivers.jar
 
the class DAO provides the Connection to an Oracle database...
 
so far, everything is fine... but here's the thing... this webapp gets replicated... 
the whole dir, because there are other instances of this system with small changes, 
and we didn't have the time to create a self-configuring app to allow that... so we 
copy the whole dir and make the necessary changes... BUT... the classes never 
change... only the JSPs... AND another thing that may change is the database (and of 
course DAO)... so how it is done?
 
we have /fap with DAO.class pointing to a specific db URL and;
we have (for example) /fap2 with a few JSPs changes and DAO.class pointing to another 
URL.
 
this of course sux! If we wanna change the database of a specific webapp we have to 
re-compile DAO and place it there... and if we change a class (any class) we have to 
update it in ALL the contexts...
 
What I want:
I would like to place the package finep and the OracleDrivers in the global context 
(c:\tomcat\common\classes, \lib), so all would be pretty and centralized; and create 
something like a Connection Dispatcher (also in the global context) that would receive 
requests from the JSPs and provide a Connection to the specific URL based in which 
context that JSP was when the request was made. I don't know if that's possible... I'm 
just guessing... of course I want do this as painless as possible... cuz we have like 
80 classes and more than 150 JSPs...
 
to confuse??? My english also sux... sorry!
 
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332




RE: Need Ideas... big problem! (long)

2002-07-09 Thread Christian J. Dechery

Sorry... but could u explain this a little furhter? I'm not familiar with JNDI.
 
thanks
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 09/07/02 16:41  
Why don't you store the JDBC URL in JNDI and have DAO look it up 
dynamically 

Bob Kranson 
Software Technical Support Analyst 
UNIFACE and Optimal Products Technical Support 
U.S. Support Center 888-551-0404 
New Calls: [EMAIL PROTECTED] 
31440 Northwestern Hwy, Farmington Hills, MI 48334-2564 
(248)737-7300 x12702 Fax:(248)737-7574 


 -Original Message- 
 From: Christian J. Dechery [ mailto:[EMAIL PROTECTED]] 
 Sent: Tuesday, July 09, 2002 2:38 PM 
 To: [EMAIL PROTECTED] 
 Subject: Need Ideas... big problem! (long) 
 
 
 I have a huge problem here... and I can't think of a simple 
 solution for it, I'm hoping u guys can give some light. :) 
 
 Let me first describe the environment here, then the problem. 
 
 We have here a webapp called FAP (c:\tomcat\fap). It is 
 composed of: /fap/*.jsp (like a hundred of them) 
 /fap/WEB-INF/classes/finep (this package finep has a lot of 
 subpackages) /fap/WEB-INF/classes/finep/DAO.class -- here 
 the problem resides... /fab/lib/OracleDrivers.jar 
 
 the class DAO provides the Connection to an Oracle database... 
 
 so far, everything is fine... but here's the thing... this 
 webapp gets replicated... the whole dir, because there are 
 other instances of this system with small changes, and we 
 didn't have the time to create a self-configuring app to 
 allow that... so we copy the whole dir and make the necessary 
 changes... BUT... the classes never change... only the 
 JSPs... AND another thing that may change is the database 
 (and of course DAO)... so how it is done? 
 
 we have /fap with DAO.class pointing to a specific db URL 
 and; we have (for example) /fap2 with a few JSPs changes and 
 DAO.class pointing to another URL. 
 
 this of course sux! If we wanna change the database of a 
 specific webapp we have to re-compile DAO and place it 
 there... and if we change a class (any class) we have to 
 update it in ALL the contexts... 
 
 What I want: 
 I would like to place the package finep and the 
 OracleDrivers in the global context 
 (c:\tomcat\common\classes, \lib), so all would be pretty and 
 centralized; and create something like a Connection 
 Dispatcher (also in the global context) that would receive 
 requests from the JSPs and provide a Connection to the 
 specific URL based in which context that JSP was when the 
 request was made. I don't know if that's possible... I'm just 
 guessing... of course I want do this as painless as 
 possible... cuz we have like 80 classes and more than 150 JSPs... 
 
 to confuse??? My english also sux... sorry! 
 
 
 .:| Christian J. Dechery 
 .:| FINEP - Depto. de Sistemas 
 .:| [EMAIL PROTECTED] 
 .:| (21) 2555-0332 
 
 



The contents of this e-mail are intended for the named addressee only. It 
contains information that may be confidential. Unless you are the named 
addressee or an authorized designee, you may not copy or use it, or disclose 
it to anyone else. If you received it in error please notify us immediately 
and then destroy it. 


-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]  
For additional commands, e-mail:  mailto:[EMAIL PROTECTED]  






RE: getting exception when trying to close connection

2002-06-12 Thread Christian J. Dechery

I read in the javadoc of the .close() method, that when the garbage collector runs, it 
closes the connections.
 
Well, this isn't working obviously... the thing that's keeping me from solving the 
problem is the frequency it happens... I can't understand why a connection can't be 
closed... I know of no timeouts set on oracle,and if it had... the connection AND the 
socket would be closed, don't u think? And I still have dozens of open INACTIVE 
connections on oracle...
 
A timeout on the Connection obj is also hard to believe... even because when I 
debugged it with a page opening 10 connections (just for testing, I don't have such a 
page)... 3 of them didn't close... and it was not the last three... just some random 
conns... 
 
and I guess when the finalize() method runs, its because there's no use for that 
object (in this case the DAO) anymore, right? So what would cause the exception? I'll 
try to focus on the booleans, but I don't think it'll help, since everytime I debugged 
it, the error is always on the con.close(), meaning the booleans are ok.
 
I'm hopeless!
 
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 11/06/02 18:17  
OK well, a couple answers first. The socket that is being referred to is the 
underlying (usually tcp/ip) socket that your driver uses to connect to the 
database. A connection is an abstraction from what the implementation socket 
is. A couple things could be happening with your oracle driver. First, there 
can be an inactive timeout set on your oracle database, where connections 
are closed after a timeout period to free up resources. You would get the 
same error if for instance the server on the other end lost power, and 
therefore closed the connection by being turned off. The other thing is, 
your driver could have a timeout set. I haven't used the oracle driver 
extensively, so i'm not really sure how you configure it. Look in the docs. 
The other thing you want to do is separate out those three boolean 
statements so you can determine which one is failing. Checking for null is 
not going to throw the exception so pretty much focus on your last two. (and 
look at your driver configuration docs) you may want to try this method 
instead. 
static Connection getConnection(String url, Properties info); 
//Attempts to establish a connection to the given database URL. 
In properties, you can specify driver settings. 

Zak 

-Original Message- 
From: Christian J. Dechery [ mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, June 11, 2002 12:03 PM 
To: [EMAIL PROTECTED] 
Subject: RE: getting exception when trying to close connection 


ok... there you go: 

public DAOFundos(Esquema esq) { 

if( esq==null ) { 
esq = esquemaDefault; 
} 

try { 
Class.forName( esq.getDriver() ); 
con = DriverManager.getConnection(esq.getUrl(), esq.getUser(), 
esq.getPassword()); 
} 
catch(ClassNotFoundException cnf) { 
System.out.println (Erro: driver nao encontrado! +cnf.getMessage()); 
} 
catch(SQLException sql) { 
System.out.println(Erro ao obter conexão! +sql.getMessage() ); 
} 
} 

this is the code for the default constructor... in this case the class 
Esquema contains info about: drivers, user, url and pwd. 
the driver is always oracle.jdbc.driver.OracleDriver 

thanks again 


.:| Christian J. Dechery 
.:| FINEP - Depto. de Sistemas 
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332 

 [EMAIL PROTECTED] 11/06/02 16:03  
It would be halpful to see the declaration of con, and the type of driver 
you are using 


-Original Message- 
From: Christian J. Dechery [ mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, June 11, 2002 11:41 AM 
To: [EMAIL PROTECTED] 
Subject: getting exception when trying to close connection 


I know my implementation isn't the best there is... take a look at this 
code: 

protected void finalize() 

try 

if( con!=null  !con.isClosed()  con.getAutoCommit() ) 

con.close(); 
} 
} 
catch(SQLException sqle) 

System.out.println([+this.getClass().getName()+] Não foi possível 
fechar a conexão. +sqle.toString()+\n); 
// sqle.printStackTrace(); 
} 
} 

that's what I use to TRY to close all connections... this code is in my DAO 
class. Sometimes I have up to four DAO classes instantiated in a single 
JSP... I debugged it... at least one always fails to close giving me this 
exception: I/O error: socket closed 

what does that mean? what socket? And why did all the other connections 
closed and this didn't? 

.:| Christian J. Dechery 
.:| FINEP - Depto. de Sistemas 
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332 



-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED] 
 
For additional commands, e-mail:  
mailto:[EMAIL PROTECTED]  





-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]  
For additional commands, e-mail:  mailto:[EMAIL PROTECTED]  






problem with connections not closing...

2002-06-11 Thread Christian J. Dechery

I'm experiencing here a pretty serious problem, that we can't get trough...
 
We have several classes accessing and connecting via the oracle native driver... but 
so it happens, some of these connections aren't properly closed when the class dies 
(meaning, the execution of the JSP ends).
 
I've even debugged it, there are some JSPs that opens like 4 connections, and in my 
finalize() method there's a con.close() call, never all the 4 con.close() are 
successfull, there's always at least one that fails and gives an execption. I don't 
know why.
 
Would that JDBC Realm thing help that? What is that anyway, could someone explain to 
me?
 
thanks
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332




Re: problem with connections not closing...

2002-06-11 Thread Christian J. Dechery

but I can't close the connection in each query... the connection is used by other 
objects...
I have a DAO for each class that needs access to the DB... but some of these DAOs are 
Singletons, so several objects can use one DAO and one connection to the db... so I 
can't just close it whenever I want...
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 11/06/02 11:12  
finalize() gets called on garbage collection. Which may occur a long 
time from when your are done with your connection. Which isn't the time 
to close your db connections - it should be done much earlier. Here is 
code I typically use: 

Connection con = null; 
PreparedStatement stmt = null; 
ResultSet rs = null; 
try { 
con = magicalConnectionGetter(); 
stmt = magicalStatementGetter(); 
rs = magicalResultSetGetter(); 
} catch(Throwable e) { 
//do as needed 
} finally { 
try {if (rs!=null) rs.close();}catch(Throwable e){} 
try {if (stmt!=null) stmt.close();}catch(Throwable e){} 
try {if (con!=null) con.close();}catch(Throwable e){} 
} 

Always use finally to close your database assets - it will save much 
heartache later. finally blocks always gets run - even if you issue a 
return in the try block. 

-Tim 

Christian J. Dechery wrote: 
 I'm experiencing here a pretty serious problem, that we can't get trough... 
 
 We have several classes accessing and connecting via the oracle native driver... but 
so it happens, some of these connections aren't properly closed when the class dies 
(meaning, the execution of the JSP ends). 
 
 I've even debugged it, there are some JSPs that opens like 4 connections, and in my 
finalize() method there's a con.close() call, never all the 4 con.close() are 
successfull, there's always at least one that fails and gives an execption. I don't 
know why. 
 
 Would that JDBC Realm thing help that? What is that anyway, could someone explain 
to me? 
 
 thanks 
 
 .:| Christian J. Dechery 
 .:| FINEP - Depto. de Sistemas 
 .:| [EMAIL PROTECTED] 
 .:| (21) 2555-0332 
 
 



-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]  
For additional commands, e-mail:  mailto:[EMAIL PROTECTED]  






Re: AW: problem with connections not closing...

2002-06-11 Thread Christian J. Dechery

yeah... I know what u mean, but now is kinda too late for me to change that... there 
are way too many JSPs accessing my beans (the ones who make calls to the DAOs)... so I 
want a better (simpler) solution to provide closure to all the connections?
 
I was thinking of some type os static variable to control it on the super DAO class. 
There is a super DAO class which all the DAO inherit the connection object from, I 
wrote the finalize() and cleanUp() code in there... I was thinking of a solution that 
would use this class.
 
But what about the JDBC Realm? I still don't know what it is, and what it's for.
 
Thanks
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 11/06/02 11:54  
This kind of design will give you nothing but headache. 
- The connection will be longer open than needed. 
- You must do hard work to close the connections at all 
- You have hardly control about the number of connections 

I prefer to manage the connections outside of my dao's. 
My DAO's get the connection as a parameter. 

 -Ursprüngliche Nachricht- 
 Von: Christian J. Dechery [ mailto:[EMAIL PROTECTED]] 
 Gesendet: Dienstag, 11. Juni 2002 16:42 
 An: [EMAIL PROTECTED] 
 Betreff: Re: problem with connections not closing... 
 
 
 but I can't close the connection in each query... the 
 connection is used by other objects... 
 I have a DAO for each class that needs access to the DB... 
 but some of these DAOs are Singletons, so several objects can 
 use one DAO and one connection to the db... so I can't just 
 close it whenever I want... 
 

-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]  
For additional commands, e-mail:  mailto:[EMAIL PROTECTED]  






getting exception when trying to close connection

2002-06-11 Thread Christian J. Dechery

I know my implementation isn't the best there is... take a look at this code:
 
 protected void finalize() {
  try {
   if( con!=null  !con.isClosed()  con.getAutoCommit() ) {
con.close();
   }
  }
  catch(SQLException sqle) {
   System.out.println([+this.getClass().getName()+] Não foi possível fechar a 
conexão. +sqle.toString()+\n);
//   sqle.printStackTrace();
  }
 }

that's what I use to TRY to close all connections... this code is in my DAO class. 
Sometimes I have up to four DAO classes instantiated in a single JSP... I debugged 
it... at least one always fails to close giving me this exception: I/O error: socket 
closed
 
what does that mean? what socket? And why did all the other connections closed and 
this didn't?
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332




RE: getting exception when trying to close connection

2002-06-11 Thread Christian J. Dechery

ok... there you go:
 
  public DAOFundos(Esquema esq) {
 
  if( esq==null ) {
   esq = esquemaDefault;
  }
 
 try {
   Class.forName( esq.getDriver() );
  con = DriverManager.getConnection(esq.getUrl(), esq.getUser(), 
esq.getPassword());
 }
 catch(ClassNotFoundException cnf) {
  System.out.println (Erro: driver nao encontrado! +cnf.getMessage());
 }
 catch(SQLException sql) {
  System.out.println(Erro ao obter conexão! +sql.getMessage() );
 }
}

this is the code for the default constructor... in this case the class Esquema 
contains info about: drivers, user, url and pwd.
the driver is always oracle.jdbc.driver.OracleDriver
 
thanks again
 
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 11/06/02 16:03  
It would be halpful to see the declaration of con, and the type of driver 
you are using 


-Original Message- 
From: Christian J. Dechery [ mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, June 11, 2002 11:41 AM 
To: [EMAIL PROTECTED] 
Subject: getting exception when trying to close connection 


I know my implementation isn't the best there is... take a look at this 
code: 

protected void finalize() { 
try { 
if( con!=null  !con.isClosed()  con.getAutoCommit() ) { 
con.close(); 
} 
} 
catch(SQLException sqle) { 
System.out.println([+this.getClass().getName()+] Não foi possível 
fechar a conexão. +sqle.toString()+\n); 
// sqle.printStackTrace(); 
} 
} 

that's what I use to TRY to close all connections... this code is in my DAO 
class. Sometimes I have up to four DAO classes instantiated in a single 
JSP... I debugged it... at least one always fails to close giving me this 
exception: I/O error: socket closed 

what does that mean? what socket? And why did all the other connections 
closed and this didn't? 

.:| Christian J. Dechery 
.:| FINEP - Depto. de Sistemas 
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332 



-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]  
For additional commands, e-mail:  mailto:[EMAIL PROTECTED]  






CrossContext. Is there a easier solution?

2002-06-06 Thread Christian J. Dechery

As I can see, 
 
and for what I've tried to acomplish, this CrossContext thing is no picnic. It isn't 
easy to apply or use.
Isn't there a easier of doing this?
 
For instance, if I have a webserver and I want all the webapps to look in only one dir 
for images... how would I do that?
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332




Re: creating global context

2002-05-31 Thread Christian J. Dechery

request dispatcher? I don't understand... sorry, I can't simply include files that are 
in this context???
 
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 29/05/02 16:41  

In server.xml: 
Context path=/examples docBase=examples debug=0 reloadable=true 
crossContext=true/ 
The crossContext attribute true implies that servlets/jsps in other 
contexts can access resources from this context with the help of a 
RequestDispatcher. 

RS 





Christian J. Dechery  [EMAIL PROTECTED]  on 05/29/2002 04:21:05 PM 

Please respond to Tomcat Users List  [EMAIL PROTECTED]  

To:  [EMAIL PROTECTED]  
cc: 

Subject: Re: creating global context 

sorry, I'm kinda newbie to web.xml... could u exemplify? 

thanks 


.:| Christian J. Dechery 
.:| FINEP - Depto. de Sistemas 
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332 

 [EMAIL PROTECTED] 29/05/02 16:20  

You could set the attribute crosscontext=true. And then access resources 
across various contexts. 

RS 





Christian J. Dechery  [EMAIL PROTECTED]  on 05/29/2002 03:57:13 PM 


Please respond to Tomcat Users List  [EMAIL PROTECTED]  

To:  [EMAIL PROTECTED]  
cc: 

Subject: creating global context 

How do I create a global context? 

I want to able to include JSP files (as well as images, etc) from this 
context across all my webapps. This is possible right? 

thanks 

.:| Christian J. Dechery 
.:| FINEP - Depto. de Sistemas 
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332 










-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED] 
 
For additional commands, e-mail:  
mailto:[EMAIL PROTECTED]  












-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]  
For additional commands, e-mail:  mailto:[EMAIL PROTECTED]  






can't get context to see global classes/jars

2002-05-31 Thread Christian J. Dechery

Why can't I get this right? Is Tomcat crazy?
 
I have a set of classes (the package is called finep) and the oracle drivers (a file 
named classes12.jar).
 
Well... if I place finep and the oracle drivers in the webapp/WEB-INF dir (finep in 
/classes, classes12.jar in /lib) everything works fine... if I try and place finep in 
$CATALINA_HOME/classes and $CATALINA_HOME/lib nothing works..
 
I tried unpacking classes12.jar in /classes, still doesn't work... I tried to pack 
everything into jars and place it in /lib... still doesn't work... what is the matter 
with this thing? Is it impossible to get this working? I have several webapps that 
needs these (finep and oracle drivers).
 
Thanks
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332




RE: can't get context to see global classes/jars

2002-05-31 Thread Christian J. Dechery

I've tried that too... doesn't work... and it says in the documentation that 
/common/' should not be used for that purpose...
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 31/05/02 10:50  
put classes12.jar in $CATALINA_HOME/common/lib and finep in 
$CATALINA_HOME/common/classes. 

Jack Li 

-Original Message- 
From: Christian J. Dechery [ mailto:[EMAIL PROTECTED]] 
Sent: Friday, May 31, 2002 8:22 AM 
To: [EMAIL PROTECTED] 
Subject: can't get context to see global classes/jars 


Why can't I get this right? Is Tomcat crazy? 

I have a set of classes (the package is called finep) and the oracle 
drivers (a file named classes12.jar). 

Well... if I place finep and the oracle drivers in the webapp/WEB-INF dir 
(finep in /classes, classes12.jar in /lib) everything works fine... if I try 
and place finep in $CATALINA_HOME/classes and $CATALINA_HOME/lib nothing 
works.. 

I tried unpacking classes12.jar in /classes, still doesn't work... I tried 
to pack everything into jars and place it in /lib... still doesn't work... 
what is the matter with this thing? Is it impossible to get this working? I 
have several webapps that needs these (finep and oracle drivers). 

Thanks 

.:| Christian J. Dechery 
.:| FINEP - Depto. de Sistemas 
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332 


-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]  
For additional commands, e-mail:  mailto:[EMAIL PROTECTED]  






Re: can't get context to see global classes/jars

2002-05-31 Thread Christian J. Dechery

yes... I'm using Class.forName()... but now, I can get NO classes.. not even finep 
classes are found... I tried placing them in ALL the four possibilities: unpacked in 
/classes and /common/classes and packed as jar in /lib and /common/lib
 
it seems to me that the ClassLoader are completely crazy... It only works if I place 
everything in the webapp...
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 31/05/02 11:32  
Is finep trying to load the Oracle driver using Class.forName(String 
aClassName)? 

You should be using 

Thread.currentThread().getContextClassLoader().loadClass(String aClassName); 

That will find your Oracle Driver across multiple classloaders. It is the 
Java2 way of loading classes and necessary in an environment like Tomcat 
with its multiple classloaders. 

Jake 

At 09:22 AM 5/31/2002 -0300, you wrote: 
Why can't I get this right? Is Tomcat crazy? 
 
I have a set of classes (the package is called finep) and the oracle 
drivers (a file named classes12.jar). 
 
Well... if I place finep and the oracle drivers in the webapp/WEB-INF dir 
(finep in /classes, classes12.jar in /lib) everything works fine... if I 
try and place finep in $CATALINA_HOME/classes and $CATALINA_HOME/lib 
nothing works.. 
 
I tried unpacking classes12.jar in /classes, still doesn't work... I tried 
to pack everything into jars and place it in /lib... still doesn't work... 
what is the matter with this thing? Is it impossible to get this working? 
I have several webapps that needs these (finep and oracle drivers). 
 
Thanks 
 
.:| Christian J. Dechery 
.:| FINEP - Depto. de Sistemas 
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332 





Re: can't get context to see global classes/jars

2002-05-31 Thread Christian J. Dechery

Just tryed it... didn't work... I switched the Class.forName() for the new method u 
described... it gives me the exact problem... driver not found 
 
the class that is trying to acess the oracle driver is called DAOFundos located in 
$CATALINA_HOME/classes, the oracle driver (classes12.jar) is located in 
$CATALINA_HOME/lib
 
I can't get it to work...
 
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 31/05/02 11:35  
yes... I'm using Class.forName()... but now, I can get NO classes.. not even finep 
classes are found... I tried placing them in ALL the four possibilities: unpacked in 
/classes and /common/classes and packed as jar in /lib and /common/lib 

it seems to me that the ClassLoader are completely crazy... It only works if I place 
everything in the webapp... 

.:| Christian J. Dechery 
.:| FINEP - Depto. de Sistemas 
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332 

 [EMAIL PROTECTED] 31/05/02 11:32  
Is finep trying to load the Oracle driver using Class.forName(String 
aClassName)? 

You should be using 

Thread.currentThread().getContextClassLoader().loadClass(String aClassName); 

That will find your Oracle Driver across multiple classloaders. It is the 
Java2 way of loading classes and necessary in an environment like Tomcat 
with its multiple classloaders. 

Jake 

At 09:22 AM 5/31/2002 -0300, you wrote: 
Why can't I get this right? Is Tomcat crazy? 
 
I have a set of classes (the package is called finep) and the oracle 
drivers (a file named classes12.jar). 
 
Well... if I place finep and the oracle drivers in the webapp/WEB-INF dir 
(finep in /classes, classes12.jar in /lib) everything works fine... if I 
try and place finep in $CATALINA_HOME/classes and $CATALINA_HOME/lib 
nothing works.. 
 
I tried unpacking classes12.jar in /classes, still doesn't work... I tried 
to pack everything into jars and place it in /lib... still doesn't work... 
what is the matter with this thing? Is it impossible to get this working? 
I have several webapps that needs these (finep and oracle drivers). 
 
Thanks 
 
.:| Christian J. Dechery 
.:| FINEP - Depto. de Sistemas 
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332 







global resources

2002-05-29 Thread Christian J. Dechery

I can't seem to get my classes as global. 
 
I want them to be acessed by all applications... so I placed it under 
$CATALINA_HOME/classes and $CATALINA_HOME/lib right?
 
Well... when I do that, either two things happen: it doesn't find the classes and 
nothing works, or it gives me a crazy error regarding ServletException and some cast 
error.
 
any clues?
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332




RE: global resources

2002-05-29 Thread Christian J. Dechery

I tried that too... if I do that Tomcat doesn't even start.
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 29/05/02 15:06  
You should use $CATALINA_HOME/commom/classes and $CATALINA_HOME/common/lib 

-Original Message- 
From: Christian J. Dechery [ mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, May 29, 2002 10:59 AM 
To: [EMAIL PROTECTED] 
Subject: global resources 


I can't seem to get my classes as global. 

I want them to be acessed by all applications... so I placed it under 
$CATALINA_HOME/classes and $CATALINA_HOME/lib right? 

Well... when I do that, either two things happen: it doesn't find the 
classes and nothing works, or it gives me a crazy error regarding 
ServletException and some cast error. 

any clues? 

.:| Christian J. Dechery 
.:| FINEP - Depto. de Sistemas 
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332 


-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]  
For additional commands, e-mail:  mailto:[EMAIL PROTECTED]  






Re: global resources

2002-05-29 Thread Christian J. Dechery

I want both... I have some classes that are unpacked, that I'd put in the 
common/classes dir... and some jars... along with them is the oracle driver 
(classes12.jar)... when I execute the JSP I get the exception thrown when the driver 
can't be found... if I take this file (classes12.jar) and place it in 
mywebapp/WEB-INF/lib it works fine...
 
it feels to me that this package is the only one tomcat isn't beeing able to share 
across webapps... all other classes and libs works fine...
 
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 29/05/02 15:17  
It might help if you described what you're doing in a little more detail. 

What are these classes you want commonly accessible? 

Are they in jars? Packed correctly, etc.? 

Please elaborate. 

fillup 


On 5/29/02 11:07 AM, Christian J. Dechery  [EMAIL PROTECTED]  wrote: 

 I tried that too... if I do that Tomcat doesn't even start. 
 
 .:| Christian J. Dechery 
 .:| FINEP - Depto. de Sistemas 
 .:| [EMAIL PROTECTED] 
 .:| (21) 2555-0332 
 
 [EMAIL PROTECTED] 29/05/02 15:06  
 You should use $CATALINA_HOME/commom/classes and $CATALINA_HOME/common/lib 
 
 -Original Message- 
 From: Christian J. Dechery [ mailto:[EMAIL PROTECTED]] 
 Sent: Wednesday, May 29, 2002 10:59 AM 
 To: [EMAIL PROTECTED] 
 Subject: global resources 
 
 
 I can't seem to get my classes as global. 
 
 I want them to be acessed by all applications... so I placed it under 
 $CATALINA_HOME/classes and $CATALINA_HOME/lib right? 
 
 Well... when I do that, either two things happen: it doesn't find the 
 classes and nothing works, or it gives me a crazy error regarding 
 ServletException and some cast error. 
 
 any clues? 
 
 .:| Christian J. Dechery 
 .:| FINEP - Depto. de Sistemas 
 .:| [EMAIL PROTECTED] 
 .:| (21) 2555-0332 
 


-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]  
For additional commands, e-mail:  mailto:[EMAIL PROTECTED]  






global resources (2)

2002-05-29 Thread Christian J. Dechery

According to Tomcat's config, I should places classes and packages in /classes and 
/lib, not /common/classes and /common/lib.
 
Altough neither is working for me... :/
 
http://jakarta.apache.org/tomcat/tomcat-4.0-doc/class-loader-howto.html
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332




creating global context

2002-05-29 Thread Christian J. Dechery

How do I create a global context?
 
I want to able to include JSP files (as well as images, etc) from this context across 
all my webapps. This is possible right?
 
thanks
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332




Re: global resources

2002-05-29 Thread Christian J. Dechery

but I just have some beans acessing a an Oracle database...
 
the only thing NOT working is the oracle drivers (classes12.jar, which I tried placing 
both in /common/lib and /lib)... and all the other classes (now in /common/lib) are 
working fine.
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 29/05/02 16:05  
Hello Christian, 

By chance, are the libraries that you put in TOMCAT_HOME/lib refer to 
libraries that you put in your webapp's WEB-INF/lib? If so, this just 
isn't going to work. The WEB-INF/lib libraries can see libraries in 
TOMCAT_HOME/lib, but not the other way around. 

For instance, the developers at Log4j say that you should have 
log4j.jar in each separate webapp's WEB-INF/lib directory. However, 
this imposes itself upon any libraries that are using Log4j. They 
will need to also be inside WEB-INF/lib as well where, if Log4j was 
designed a non-static way where it could exist in TOMCAT_HOME/lib and 
serve all webapps with Loggers without running into each other, then 
you could have the libraries that reference log4j safely in 
TOMCAT_HOME/lib. 

If you didn't understand that, if all else fails, just put everything 
in WEB-INF/lib except for XML and DOM libraries, which are forbidden 
in the child classloader, and stuff like DBCP which both Tomcat and 
your webapp need access to (TOMCAT_HOME/common/lib). 

Jake 

Wednesday, May 29, 2002, 12:59:01 PM, you wrote: 

CJD I can't seem to get my classes as global. 

CJD I want them to be acessed by all applications... so I placed it under 
$CATALINA_HOME/classes and $CATALINA_HOME/lib right? 

CJD Well... when I do that, either two things happen: it doesn't find the classes and 
nothing works, or it gives me a crazy error regarding ServletException and some cast 
error. 

CJD any clues? 

CJD .:| Christian J. Dechery 
CJD .:| FINEP - Depto. de Sistemas 
CJD .:| [EMAIL PROTECTED] 
CJD .:| (21) 2555-0332 




-- 
Best regards, 
Jacob mailto:[EMAIL PROTECTED] 


-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]  
For additional commands, e-mail:  mailto:[EMAIL PROTECTED]  






global resources (better explained)

2002-05-29 Thread Christian J. Dechery

I have a set of beans, the package names are finep and christian.
 
both are in $CATALINA_HOME/classes
 
calls to these classes occur normally... the problem is, that among these classes, 
some of them makes calls to the oracle driver... the oracle drivers (classes12.jar) 
are in $CATALINA_HOME/lib
 
like this it's not working... but if I take classes12.jar and place it in 
mywebapp/WEB-INF/lib, everything works fine...
 
does this behavious say something? I can't figure it out... I don't want to have this 
file (classes12.jar, which is kinda big) copied to ALL my webapps... 
 
thanks again
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332




Re: creating global context

2002-05-29 Thread Christian J. Dechery

sorry, I'm kinda newbie to web.xml... could u exemplify?
 
thanks
 
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 29/05/02 16:20  

You could set the attribute crosscontext=true. And then access resources 
across various contexts. 

RS 





Christian J. Dechery  [EMAIL PROTECTED]  on 05/29/2002 03:57:13 PM 

Please respond to Tomcat Users List  [EMAIL PROTECTED]  

To:  [EMAIL PROTECTED]  
cc: 

Subject: creating global context 

How do I create a global context? 

I want to able to include JSP files (as well as images, etc) from this 
context across all my webapps. This is possible right? 

thanks 

.:| Christian J. Dechery 
.:| FINEP - Depto. de Sistemas 
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332 










-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]  
For additional commands, e-mail:  mailto:[EMAIL PROTECTED]  






Re: creating global context

2002-05-29 Thread Christian J. Dechery

thanks a lot... that will solve a whole bunch of problems
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332

 [EMAIL PROTECTED] 29/05/02 16:41  

In server.xml: 
Context path=/examples docBase=examples debug=0 reloadable=true 
crossContext=true/ 
The crossContext attribute true implies that servlets/jsps in other 
contexts can access resources from this context with the help of a 
RequestDispatcher. 

RS 





Christian J. Dechery  [EMAIL PROTECTED]  on 05/29/2002 04:21:05 PM 

Please respond to Tomcat Users List  [EMAIL PROTECTED]  

To:  [EMAIL PROTECTED]  
cc: 

Subject: Re: creating global context 

sorry, I'm kinda newbie to web.xml... could u exemplify? 

thanks 


.:| Christian J. Dechery 
.:| FINEP - Depto. de Sistemas 
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332 

 [EMAIL PROTECTED] 29/05/02 16:20  

You could set the attribute crosscontext=true. And then access resources 
across various contexts. 

RS 





Christian J. Dechery  [EMAIL PROTECTED]  on 05/29/2002 03:57:13 PM 


Please respond to Tomcat Users List  [EMAIL PROTECTED]  

To:  [EMAIL PROTECTED]  
cc: 

Subject: creating global context 

How do I create a global context? 

I want to able to include JSP files (as well as images, etc) from this 
context across all my webapps. This is possible right? 

thanks 

.:| Christian J. Dechery 
.:| FINEP - Depto. de Sistemas 
.:| [EMAIL PROTECTED] 
.:| (21) 2555-0332 










-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED] 
 
For additional commands, e-mail:  
mailto:[EMAIL PROTECTED]  












-- 
To unsubscribe, e-mail:  mailto:[EMAIL PROTECTED]  
For additional commands, e-mail:  mailto:[EMAIL PROTECTED]  






auto-prepend (include) file

2002-05-21 Thread Christian J. Dechery

Is it possible to have a config in web.xml (or anywhere for that matter) to have a 
file (a JSP file) included in all the JSPs?
 
.:| Christian J. Dechery
.:| FINEP - Depto. de Sistemas
.:| [EMAIL PROTECTED]
.:| (21) 2555-0332