RE: Using database tables for resource bundles

2004-02-02 Thread Johan Wasserman - CPX Mngd Services
Regarding using a database to provide resource bundles;
James Mitchell developed a nifty extention called 'OJBMessageResources'
that uses OJB and there where talk of a new version using Hibernate...


I'm also about to release another implementation that uses Hibernate for
those who don't want the required OJB internal tables.stay
tunedmore to come.


Does anyone know (James, if you're listening) if the Hibernate version
where made available or if there is something else available (that
doesn't use OJB)?

Thanks (and kudos to James for the OJB version),
Johan Wasserman 
For: Comparex Africa (Pty) Ltd 
+27 (0) 83 326 7339 (Mobile) 
+27 (0) 11 266 1110 (Tel) 
+27 (0) 11 266 1099 (Fax) 
Mailto:[EMAIL PROTECTED]
http://www.comparex.co.za/
Company Registration Number 1993/003683/07 
NOTICE: This message and any attachments are confidential and intended
solely for the addressee.  If you have received this message in error,
please notify Johan Wasserman at Comparex Africa (Pty) Ltd immediately,
telephone number +27 (0) 11 266 1110.  Any unauthorized use, alteration
or dissemination is prohibited.  Comparex Africa (Pty) Ltd accepts no
liability whatsoever for any loss whether it be direct, indirect or
consequential, arising from information made available and actions
resulting there from.



-Original Message-
From: James Mitchell [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 25, 2003 6:17 PM
To: Struts Users Mailing List
Subject: Re: Using database tables for resource bundles


On Tue, 2003-03-25 at 10:30, Robert Leland wrote:
> Rahul wrote:
> > Hi,
> > 
> > We are developing a multilingual system using struts 1.1 and j2ee 
> > 1.3.
> > 
> > I need to know whether we can use backend database tables for 
> > providing all the messages i.e. whether the messages can be provided

> > by a set of java class rather than relying on resource files 
> > residing on the server.
> 
> James Mitchell developed a version of this.
> It is in the jakarta-commons-sandbox/resources.
> I haven't used this myself though. For 1.2 we plan
> on making the message resources in struts a wrapper
> around these classes. Until that point you'll need to
> provide your own glue.

Cool, I wasn't aware that it was added to commons-sandbox.  

I initially released this extension on http://sourceforge.net/struts
called 'OJBMessageResources'.  This particular implementation uses OJB
under the covers.  

It is very simple to use.  The best part is that you don't have to
change anything in your application that already uses MessageResources. 
You can even use both properties files and database in the same
application. (Props for some and db for others)

Complete details are available in the download, and I'm here (almost 24
X 7) if you need assistance with setting things up.

I'm also about to release another implementation that uses Hibernate for
those who don't want the required OJB internal tables.stay
tunedmore to come.

> 
> -Rob
> 
> 



-- 
James Mitchell
Software Developer/Struts Evangelist
http://www.open-tools.org




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


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



RE: [Q]Tags: Lookforward to create the correct session name for bean?

2003-09-29 Thread Johan Wasserman - CPX Mngd Services
Are my questions real difficult, or s stupid?

No-one's ever answered any of 'em, if only I knew why.

{:(

-Original Message-----
From: Johan Wasserman - CPX Mngd Services 
Sent: Monday, September 29, 2003 8:17 AM
To: Struts Users Mailing List
Subject: [Q]Tags: Lookforward to create the correct session name for
bean?


Hi,
Is there a way for a formAction to look at the tag defined in the form
(especialy the "name" attribute) so that I can create a bean and save it
in the session as the same name as the "name" attribute even before the
tag needs it.

Thanks,
Johan.

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



[Q]Tags: Lookforward to create the correct session name for bean?

2003-09-28 Thread Johan Wasserman - CPX Mngd Services
Hi,
Is there a way for a formAction to look at the tag defined in the form
(especialy the "name" attribute) so that I can create a bean and save it
in the session as the same name as the "name" attribute even before the
tag needs it.

Thanks,
Johan.


Struts-menu or not, dynamic menu from bean.

2003-09-24 Thread Johan Wasserman - CPX Mngd Services
Is there a menu builder, like struts-menu, available that will build a
tree menu (and other menu types) from a bean?

Anyone got struts-menu converted to get its data from a bean?

Thanks in advance,
Johan


RE: HTTP 404 Not Found on Actions - SOLVED

2003-08-18 Thread Johan Wasserman - CPX Mngd Services
Nope, nothing to do with struts!  It's something to do with how Tomcat /
Apache is set up.  When I try via Tomcat only it works.  I'll have to
relook the Tomcat/Apache thing (mod_jk), if ANYBODY has a tried and
trusted way of setting this up, please let me know.

Tomcat v.  5.0.3
Apache v. 2.0.46

Sory for this "out of context".

Thanks,
Johan.

-Original Message-
From: Koni Roth [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 18, 2003 12:41 PM
To: Struts Users Mailing List
Subject: Re: HTTP 404 Not Found on Actions


Try struts 1.1 final version. Here it works ;-)

Johan Wasserman - CPX Mngd Services wrote:

> Hi.
> I'm running struts 1.1-rc2 and get a 404 when entering an unrecognized

> username & password on the logon page for struts-example (Mailreader 
> demo).  It goes to localhost/sruts-example/logon.do but with a 404 
> Page not found.  I've checked and double checked my web & 
> struts-config files, I mean they've not been changed from the 
> download.
> 
> Thanks,
> Johan Wasserman.
> 



-
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]



HTTP 404 Not Found on Actions

2003-08-18 Thread Johan Wasserman - CPX Mngd Services
Hi.
I'm running struts 1.1-rc2 and get a 404 when entering an unrecognized
username & password on the logon page for struts-example (Mailreader
demo).  It goes to localhost/sruts-example/logon.do but with a 404 Page
not found.  I've checked and double checked my web & struts-config
files, I mean they've not been changed from the download.

Thanks,
Johan Wasserman.


RE: Browser influence Session behavior

2003-04-04 Thread Johan Wasserman
LOG FILE:

 WHITH Mozilla 0.9.8 
Apr 4, 2003 1:04:57 PM jackrabit.com.dao.Table execute
INFO: select * from subscriptions where subsid='acme'
Apr 4, 2003 1:04:57 PM jackrabit.com.dao.Table execute
INFO: RETURNED 1
Apr 4, 2003 1:04:57 PM jackrabit.actions.StartAction execute
INFO: Subscriptions returned 1 entries
Apr 4, 2003 1:04:57 PM jackrabit.actions.StartAction execute
INFO: SAVING STATE UNDER SESSION 3C9CDA8EA0367A6B96C6854A509F8A8A
Apr 4, 2003 1:04:57 PM jackrabit.actions.StartAction execute
INFO: SUCCESS - FORWARD
Apr 4, 2003 1:04:58 PM jackrabit.actions.AppAction execute
INFO: INTO APP ACTION
Apr 4, 2003 1:04:58 PM jackrabit.actions.AppAction execute
INFO: SESSION FOUND AT B4E5EC78531786E823C3513990DF15CB
Apr 4, 2003 1:04:58 PM org.apache.struts.action.RequestProcessor
processException
WARNING: Unhandled Exception thrown: class
java.lang.NullPointerException
Apr 4, 2003 1:04:58 PM org.apache.jk.server.JkCoyoteHandler action
INFO: RESET 
 WHITH Netscape Navigator 
Apr 4, 2003 1:05:18 PM org.apache.jk.common.ChannelSocket
processConnection
INFO: connection timeout reached
Apr 4, 2003 1:05:19 PM org.apache.jk.common.ChannelSocket
processConnection
INFO: connection timeout reached
Apr 4, 2003 1:06:17 PM jackrabit.com.dao.Table execute
INFO: select * from subscriptions where subsid='acme'
Apr 4, 2003 1:06:17 PM jackrabit.com.dao.Table execute
INFO: RETURNED 1
Apr 4, 2003 1:06:17 PM jackrabit.actions.StartAction execute
INFO: Subscriptions returned 1 entries
Apr 4, 2003 1:06:17 PM jackrabit.actions.StartAction execute
INFO: SAVING STATE UNDER SESSION 719869CF5F6A58002D7335AEB735FEF2
Apr 4, 2003 1:06:17 PM jackrabit.actions.StartAction execute
INFO: SUCCESS - FORWARD
Apr 4, 2003 1:06:18 PM jackrabit.actions.AppAction execute
INFO: INTO APP ACTION
Apr 4, 2003 1:06:18 PM jackrabit.actions.AppAction execute
INFO: SESSION FOUND AT 719869CF5F6A58002D7335AEB735FEF2
Apr 4, 2003 1:06:18 PM jackrabit.actions.AppAction execute
INFO: STATE Acme Company
Apr 4, 2003 1:06:18 PM jackrabit.actions.AppAction execute
INFO: NOT LOGGED ON - GOING TO LOGON
Apr 4, 2003 1:06:18 PM jackrabit.actions.InitLogon execute
INFO: SUCCESS - FORWARDING
Apr 4, 2003 1:06:19 PM org.apache.struts.util.PropertyMessageResources

INFO: Initializing, config='org.apache.struts.taglib.html.LocalStrings',
returnNull=true
Apr 4, 2003 1:06:20 PM jackrabit.actions.AppAction execute
INFO: INTO APP ACTION
Apr 4, 2003 1:06:20 PM jackrabit.actions.AppAction execute
INFO: SESSION FOUND AT 719869CF5F6A58002D7335AEB735FEF2
Apr 4, 2003 1:06:20 PM jackrabit.actions.AppAction execute
INFO: STATE Acme Company
Apr 4, 2003 1:06:20 PM jackrabit.actions.AppAction execute
INFO: NOT LOGGED ON - GOING TO LOGON
Apr 4, 2003 1:06:20 PM jackrabit.actions.InitLogon execute
INFO: SUCCESS - FORWARDING

-----Original Message-
From: Johan Wasserman 
Sent: 04 April 2003 13:36
To: [EMAIL PROTECTED]
Subject: Browser influence Session behavior

Hi,
 
I have an initial page where the company name is entered and that
forwards to a main page (with 3 frames) that loads the header, sidebar
and logon page.  I save a State bean in the session after the company is
validated (against a db) and then use the company name from the State
bean on the logon page.  With Konqueror and Netscape I have no problems
in getting the bean back from the session, but with Mozilla a new
session is created and I get a nullpointer exception (the bean's not
found in the new session).
 
I have traced the session id and find that it remains the same for
Konqueror and Netscape but changes for Mozilla.
 
Anyone got any ideas?
 
Thanks in advance,
Johan.

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



Browser influence Session behavior

2003-04-04 Thread Johan Wasserman
Hi,
 
I have an initial page where the company name is entered and that
forwards to a main page (with 3 frames) that loads the header, sidebar
and logon page.  I save a State bean in the session after the company is
validated (against a db) and then use the company name from the State
bean on the logon page.  With Konqueror and Netscape I have no problems
in getting the bean back from the session, but with Mozilla a new
session is created and I get a nullpointer exception (the bean's not
found in the new session).
 
I have traced the session id and find that it remains the same for
Konqueror and Netscape but changes for Mozilla.
 
Anyone got any ideas?
 
Thanks in advance,
Johan.


RE: take over an existing HttpSession

2003-03-28 Thread Johan Wasserman
You might have found your solution already, but I just got the same type
of requirement.  I found, and is looking at, the
org.apache.catalina.session.PersistentManagerBase class (in
catalina.jar) and hopefully this will do the trick for me.  Also look at
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/manager.html on
how to set up the manager and state store.  I'm thinking in the lines of
saving the session ID in the user's logon database. So if the user logs
on to another terminal and he already has an session id, then I'll try
to use the state store to retrieve the old session and loading its
contents into the new session before invalidating the old one.

If anyone has worked with the PersistentManagerBase before, helpful
hints will be appreciated.

Happy coding.
Johan Wasserman

-Original Message-
From: Dmitri Ilyin [mailto:[EMAIL PROTECTED] 
Sent: 24 March 2003 20:01
To: [EMAIL PROTECTED]
Subject: Re: take over an existing HttpSession


"Dan Tran" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
> With this  design idea, I am sure you will need to place a collection
to
> store all active sessions. Vector collection type will to do job to
protect
> multi threaded situation.
>
> You will  need a SessionListener to remove the expired session from
servlet
> context.
>
> You will need to know what to copy from old session to new session.
This
is
> the hardest one I beleive since struts do lots of this stuff behind
the
> scene, you may need to know struts code to do this work.
>
> Are you sure you want to do this? sound like a mantainent nightmare
for me
> ;-)
Sure I don't. But i probably must ...
I'm not using Struts a lot, so the last issue must not be critical for
me.
My application will be ported to Struts later and then i will have to
see if
it will also work for Struts but later

>
> -D
> - Original Message -
> From: "Dmitri Ilyin" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, March 24, 2003 9:23 AM
> Subject: Re: take over an existing HttpSession
>
>
> > Thank you Dan.
> >
> > I will try it this way. I don't see any problem with multithreading
here.
> I
> > will not change the "old" session i will invalidate it. What do you
> think??
> >
> > "Dan Tran" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
> > news:[EMAIL PROTECTED]
> > > Just an idea!!
> > >
> > > Store all your sessions's reference  in the servelt context and
when a
> new
> > > session is create, check against the session list in the servelt
> context,
> > > copy over data from old session to new session, and destroy the
old
> > session
> > >
> > > Then You have to deal with all kind of multithreaded  and
usibility
> > issues.
> > > Sound scary ;-)
> > >
> > > Good luck
> > >
> > > - Original Message -
> > > From: "Dmitri Ilyin" <[EMAIL PROTECTED]>
> > > To: <[EMAIL PROTECTED]>
> > > Sent: Monday, March 24, 2003 5:59 AM
> > > Subject: Re: take over an existing HttpSession
> > >
> > >
> > > >
> > > > "Stephen Smithstone" <[EMAIL PROTECTED]> schrieb im
> Newsbeitrag
> > > > news:[EMAIL PROTECTED]
> > > > > Use the servlet context to store the details in instead of the
> session
> > > > context
> > > > > and the label it via a the users username or something
> > > > Thank you Stephen, that's Ok but i also have to invalidate an
"old
> > > session",
> > > > so the user can only have one session at time.
> > > >
> > > > >
> > > > >
> > > > >
> > > > > On Monday 24 March 2003 12:40 pm, Dmitri Ilyin wrote:
> > > > > > Hi,
> > > > > >
> > > > > > i'm may be out of topic. But i think there are a lot of
gurus
here
> > > they
> > > > > > could help me.
> > > > > >
> > > > > > I have to implement one feature in my application for that
there
> is
> > > may
> > > > be
> > > > > > already a solution here.
> > > > > >
> > > > > > Szenario:
> > > > > > A user logged on in application. He dose some  work, dosn't
> logged
> > > out
> > > > and
> > > > > > goes to another workstation. In new workstation he logged in
> &g

RE: [newbie]dbcp pools with Struts... the saga continues

2003-03-26 Thread Johan Wasserman
Wooohooo, I think I got my solution;
Here's the code:

import java.sql.*;
import org.apache.commons.dbcp.*;
import org.apache.commons.pool.impl.*;

public class DBCPStest {
  public static void main(String[] args) 
  throws Exception {
  String url = "jdbc:postgresql://127.0.0.1:5432/mydb";
  String user = "username";
  String passwd = "password";

GenericObjectPool geoPool =
  new GenericObjectPool(null);
DriverManagerConnectionFactory cnnFactory =
  new DriverManagerConnectionFactory(url, user, passwd);

PoolableConnectionFactory poolableCnnFactory =
  new
PoolableConnectionFactory(cnnFactory,geoPool,null,null,false,true);

PoolingDataSource dataSource =
  new PoolingDataSource(geoPool);
Connection conn = dataSource.getConnection();
  }
 }

-Original Message-
From: Ian Hunter [mailto:[EMAIL PROTECTED] 
Sent: 26 March 2003 16:44
To: Struts Users Mailing List
Subject: Re: [newbie]dbcp pools with Struts... the saga continues

Yikes.  With a big setup like that, I'm surprised there's no
automagically
configured clustered setup where the DB engine is handling all that load
sharing.  I give up... ;)

- Original Message -
From: "Johan Wasserman" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, March 26, 2003 9:30 AM
Subject: RE: [newbie]dbcp pools with Struts... the saga continues


Oh, it get much more complicated than that, I have multiple physical db
servers, databases are created round-robin style on the different
servers, a new dbserver can be added and then databases are created
there until the load is equal to the others. When the load on one server
gets too high, a database can be moved to another server, and the
companies web app gets is informed of the move, that's where the
.properties file should do its work.

-Original Message-
From: Ian Hunter [mailto:[EMAIL PROTECTED]
Sent: 26 March 2003 16:19
To: Struts Users Mailing List
Subject: Re: [newbie]dbcp pools with Struts... the saga continues

Maybe have them share a database connection, but use different databases
within that database server.  I'm not that familiar with Postgres, but
here's the idea as applied to SQL Server (Oracle would be similar)

1)  They subscribe, and your app copies everything it needs to get
running.
A new database is created called "acme" (where do you store the
customer's
name, "acme" in this case?  I'm assuming it's available to the app
somehow).

2)  In your code to get an actual connection, you get the datasource via
JNDI, then the first statement executed is "use acmeDB"

3)  Proceed as before, and now they are using their own database.

Another option would be doing multitenancy in the tables, so everyone
shares
the same database (there are advantages and disadvantages to this; you
could
have *some* groups with access to other groups' data, if that's
appropriate)

Going the other direction philosophically, yet another option would be
creating a new DB login for each customer, and the DB specifies which
database they have access to (e.g. "acme" login has default database =
"acmeDB" and "widgetco" login has default database = "widgetcoDB").  You
would have to set the username and password in the datasource before
getting
the connections, and I'm not sure exactly how/if that would work, but it
would imply another layer of "security" in a way...

- Original Message -
From: "Johan Wasserman" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, March 26, 2003 9:01 AM
Subject: RE: [newbie]dbcp pools with Struts... the saga continues


Problem is, as soon as a new company subscribes, I have automated
processes to copy the app from [example] http://myweb.com/template to
http://myweb.com/acme and create the relevant .propperties and .xml
files, etc... I even automate the creation of the new "acme" database
from a postgres template database.  I can automate the addition of a
datasource in server.xml, but then the server needs to restart and I
cannot automate the addition of another constant in my Constants class.

-Original Message-
From: Ian Hunter [mailto:[EMAIL PROTECTED]
Sent: 26 March 2003 15:48
To: Struts Users Mailing List
Subject: Re: [newbie]dbcp pools with Struts... the saga continues

You should be able to set up multiple database connections in
server.xml; I
don't see why there's a problem.  As long as you're using unique names
for
the resources, you should be OK.  BTW, a "standard" for naming such
things
would be "com.mycompany.myapp.Constants.DATABASE_KEY" -- not likely to
ever
step on someone else's resource name that way.

I have a Tomcat instance with two separate db

RE: [newbie]dbcp pools with Struts... the saga continues

2003-03-26 Thread Johan Wasserman
Oh, it get much more complicated than that, I have multiple physical db
servers, databases are created round-robin style on the different
servers, a new dbserver can be added and then databases are created
there until the load is equal to the others. When the load on one server
gets too high, a database can be moved to another server, and the
companies web app gets is informed of the move, that's where the
.properties file should do its work.

-Original Message-
From: Ian Hunter [mailto:[EMAIL PROTECTED] 
Sent: 26 March 2003 16:19
To: Struts Users Mailing List
Subject: Re: [newbie]dbcp pools with Struts... the saga continues

Maybe have them share a database connection, but use different databases
within that database server.  I'm not that familiar with Postgres, but
here's the idea as applied to SQL Server (Oracle would be similar)

1)  They subscribe, and your app copies everything it needs to get
running.
A new database is created called "acme" (where do you store the
customer's
name, "acme" in this case?  I'm assuming it's available to the app
somehow).

2)  In your code to get an actual connection, you get the datasource via
JNDI, then the first statement executed is "use acmeDB"

3)  Proceed as before, and now they are using their own database.

Another option would be doing multitenancy in the tables, so everyone
shares
the same database (there are advantages and disadvantages to this; you
could
have *some* groups with access to other groups' data, if that's
appropriate)

Going the other direction philosophically, yet another option would be
creating a new DB login for each customer, and the DB specifies which
database they have access to (e.g. "acme" login has default database =
"acmeDB" and "widgetco" login has default database = "widgetcoDB").  You
would have to set the username and password in the datasource before
getting
the connections, and I'm not sure exactly how/if that would work, but it
would imply another layer of "security" in a way...

- Original Message -
From: "Johan Wasserman" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, March 26, 2003 9:01 AM
Subject: RE: [newbie]dbcp pools with Struts... the saga continues


Problem is, as soon as a new company subscribes, I have automated
processes to copy the app from [example] http://myweb.com/template to
http://myweb.com/acme and create the relevant .propperties and .xml
files, etc... I even automate the creation of the new "acme" database
from a postgres template database.  I can automate the addition of a
datasource in server.xml, but then the server needs to restart and I
cannot automate the addition of another constant in my Constants class.

-Original Message-
From: Ian Hunter [mailto:[EMAIL PROTECTED]
Sent: 26 March 2003 15:48
To: Struts Users Mailing List
Subject: Re: [newbie]dbcp pools with Struts... the saga continues

You should be able to set up multiple database connections in
server.xml; I
don't see why there's a problem.  As long as you're using unique names
for
the resources, you should be OK.  BTW, a "standard" for naming such
things
would be "com.mycompany.myapp.Constants.DATABASE_KEY" -- not likely to
ever
step on someone else's resource name that way.

I have a Tomcat instance with two separate dbcp pools set up now, where
one
application uses one of them, the another uses the other, and everything
is
happy.

- Original Message -
From: "Johan Wasserman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, March 26, 2003 3:40 AM
Subject: [newbie]dbcp pools with Struts... the saga continues


Hi,
This might me out of context, but please be patient with me.

I am now building a DAO (thanks for putting me on the right track Mr.
Graham) and I'm trying to find a way for the DAO to establish it's own
connection to the database pool/s created by the ActionServlet.
Again, I must stress that I am very new to struts and dbcp.  I would
prefer not to pre-established connection (using getConnection) and
passing that to the DAO, and I believe the method I'm trying to use
below should be helpful in a lot of other circumstances as well.

I know that would be very easy if my pool/s where configured in
server.xml and then would be accessable through initialContext.  But
being configured in strust-config (servlet context) I cannot set up a
 for it in web.xml.  (in servlet and not container
context, because multiple companies share the same web-server, but have
their own app connecting to their unique db instance).


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



RE: [newbie]dbcp pools with Struts... the saga continues

2003-03-26 Thread Johan Wasserman
Problem is, as soon as a new company subscribes, I have automated
processes to copy the app from [example] http://myweb.com/template to
http://myweb.com/acme and create the relevant .propperties and .xml
files, etc... I even automate the creation of the new "acme" database
from a postgres template database.  I can automate the addition of a
datasource in server.xml, but then the server needs to restart and I
cannot automate the addition of another constant in my Constants class.

-Original Message-
From: Ian Hunter [mailto:[EMAIL PROTECTED] 
Sent: 26 March 2003 15:48
To: Struts Users Mailing List
Subject: Re: [newbie]dbcp pools with Struts... the saga continues

You should be able to set up multiple database connections in
server.xml; I
don't see why there's a problem.  As long as you're using unique names
for
the resources, you should be OK.  BTW, a "standard" for naming such
things
would be "com.mycompany.myapp.Constants.DATABASE_KEY" -- not likely to
ever
step on someone else's resource name that way.

I have a Tomcat instance with two separate dbcp pools set up now, where
one
application uses one of them, the another uses the other, and everything
is
happy.

- Original Message -
From: "Johan Wasserman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, March 26, 2003 3:40 AM
Subject: [newbie]dbcp pools with Struts... the saga continues


Hi,
This might me out of context, but please be patient with me.

I am now building a DAO (thanks for putting me on the right track Mr.
Graham) and I'm trying to find a way for the DAO to establish it's own
connection to the database pool/s created by the ActionServlet.
Again, I must stress that I am very new to struts and dbcp.  I would
prefer not to pre-established connection (using getConnection) and
passing that to the DAO, and I believe the method I'm trying to use
below should be helpful in a lot of other circumstances as well.

I know that would be very easy if my pool/s where configured in
server.xml and then would be accessable through initialContext.  But
being configured in strust-config (servlet context) I cannot set up a
 for it in web.xml.  (in servlet and not container
context, because multiple companies share the same web-server, but have
their own app connecting to their unique db instance).


-
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]



[newbie]dbcp pools with Struts... the saga continues

2003-03-26 Thread Johan Wasserman
Hi,
This might me out of context, but please be patient with me.
 
I am now building a DAO (thanks for putting me on the right track Mr.
Graham) and I'm trying to find a way for the DAO to establish it's own
connection to the database pool/s created by the ActionServlet.
Again, I must stress that I am very new to struts and dbcp.  I would
prefer not to pre-established connection (using getConnection) and
passing that to the DAO, and I believe the method I'm trying to use
below should be helpful in a lot of other circumstances as well.
 
I know that would be very easy if my pool/s where configured in
server.xml and then would be accessable through initialContext.  But
being configured in strust-config (servlet context) I cannot set up a
 for it in web.xml.  (in servlet and not container
context, because multiple companies share the same web-server, but have
their own app connecting to their unique db instance).
 
So I tried to get the running instance of the action servlet by using
Class.forName() but that doesn't work (if someone could tell me why I'd
appreciate it)
Now I'm trying to access the pool by using the following:
Data Source configured in struts-config (some class paths shortened for
readability);
 

  
 
  ...other properties...
 
  
 
  ..more properties..
 

 
...more datasources...
 
Now I'm trying to "find" the pool in the following way:
 
GenericObjectPool cnnPool new GenericObjectPool(null);
PoolingDriver pooldr = new PoolingDriver();
Pooldr.registerPool("logindb", cnnPool);
Connection cnn =
DriverManager.getConnection("jdbc:apache:commons:dbcp:logindb");
.
 
I get the following error:
 
Javax.servlet.ServletException: No pool found for
jdbc:apache:commons:dbcp:logindb.
 
Could anyone help?
 
Thanks in advance.
Johan Wasserman.


RE: [newbie] findDataSource deprecated?

2003-03-24 Thread Johan Wasserman
Yep! My mistake, I've been brainbusting so much about getting a database
connection it seems there's not much left to get the versions right ;-)

I'm on Struts 1.1-rc1, downloaded last Friday.

Nope, I haven't yet got a connection.  Thank you for the other REALY
VALUBLE information, I was clearly way off the "best practice" road.

If it's at all possible for you to help, here's my situation.

I'm running postgresql.
Datapool configured in struts-config:


  

... lotsa more properties ...
  
  

... lotsa more properties ...
  


Now for the life of me! I just cannot (or will not? Lng hours), get
any code written to connect to one of the pools. 

Any help will do.

Thanks again for your previous reply David.
Regards,
Johan Wasserman

-Original Message-
From: David Graham [mailto:[EMAIL PROTECTED] 
Sent: 24 March 2003 16:52
To: [EMAIL PROTECTED]
Subject: Re: [newbie] findDataSource deprecated?

Well, there is no 1.1 RC3 so you must be referring to 1.1 beta 3.  It
looks 
like others have answered your original question but I wanted to talk
about 
your Database class.  You should never return a ResultSet into your
Action 
or form classes as it maintains an open database connection.  You need
to 
copy the results into a class like ResultSetDynaClass
http://jakarta.apache.org/commons/beanutils/api/org/apache/commons/beanu
tils/RowSetDynaClass.html

so the db connection can be closed.  Also, exposing SQL to your actions 
tightly couples them to any changes you make to your database schema.  A

useful pattern used to prevent this is called Data Access Object
http://developer.java.sun.com/developer/restricted/patterns/DataAccessOb
ject.html

David


>Hi,
>Im just now converting to rc1.3 and find that findDataSource is
>deprecated.  How do you find one of many datasources?
>
>FYI:
>--
>I have a separate class called Database with method runQuery that
>returns a resultset to my ActionForm class, I only pass DBName and
>QueryString as parameters.  So my previous code where:
>In ActionForm:
>ResultSet rs = Database.runQuery("logondb", "select username, password
>from users where username = '" + uname + "'");
>
>Many thanks in advance.
>Johan Wasserman.


_
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]



RE: [newbie] Finding datasource from pool in struts-config

2003-03-24 Thread Johan Wasserman
Sorry, that's in Struts 1.1 rc3 that I found
ActionServlet.findDataSource deprecated
 
-Original Message-
From: Johan Wasserman 
Sent: 24 March 2003 14:58
To: '[EMAIL PROTECTED]'
Subject: [newbie] Finding datasource from pool in struts-config
 
Hi,
How do you connect to a specific datasource pool (as configured in
strusts-config).
 
I have two pools specified;
key="logindb"
key="userdb"
 
ActionServlet.findDataSource is depreciated in rc 1.3
 
Thanks in advance.
Johan Wasserman


[newbie] Finding datasource from pool in struts-config

2003-03-24 Thread Johan Wasserman
Hi,
How do you connect to a specific datasource pool (as configured in
strusts-config).
 
I have two pools specified;
key="logindb"
key="userdb"
 
ActionServlet.findDataSource is depreciated in rc 1.3
 
Thanks in advance.
Johan Wasserman


[newbie] findDataSource deprecated?

2003-03-24 Thread Johan Wasserman
Hi,
Im just now converting to rc1.3 and find that findDataSource is
deprecated.  How do you find one of many datasources?
 
FYI:
--
I have a separate class called Database with method runQuery that
returns a resultset to my ActionForm class, I only pass DBName and
QueryString as parameters.  So my previous code where:
In ActionForm:
ResultSet rs = Database.runQuery("logondb", "select username, password
from users where username = '" + uname + "'");
 
Many thanks in advance.
Johan Wasserman.


RE: Retrieving Request Values After Validation (DynaValidatorForm)

2003-03-19 Thread Johan Wasserman
Hi, 

> Thanks to
> Rick Reumann's tutorials I have been able to figure out
DynaValidatorForms
> and Validator.

where can I find these tutorials?

Thanks,
Johan Wasserman

-Original Message-
From: Vinh Tran [mailto:[EMAIL PROTECTED] 
Sent: 13 March 2003 21:12
To: Struts Users Mailing List
Subject: RE: Retrieving Request Values After Validation
(DynaValidatorForm)

I may try that...for now i decided to put the attributes in session and
remove them after CRUD.  I don't like clogging up the session if I don't
have to so I may try your approach.

Thanks.

-Original Message-
From: Robert Taylor [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 13, 2003 1:57 PM
To: Struts Users Mailing List; [EMAIL PROTECTED]
Subject: RE: Retrieving Request Values After Validation
(DynaValidatorForm)


One solution is to assign the URI of SetupMyFormAction as the
input instead of the .jsp page. By doing this, Struts will
forward the user to SetupMyFormAction if validation error occurs
which will prepopulate the form accordingly but will also retain
the users input.

robert

> -Original Message-
> From: Vinh Tran [mailto:[EMAIL PROTECTED]
> Sent: Thursday, March 13, 2003 1:37 PM
> To: [EMAIL PROTECTED]
> Subject: Retrieving Request Values After Validation
(DynaValidatorForm)
>
>
> I finally have the time to experiment with DynaValidatorForm.  Thanks
to
> Rick Reumann's tutorials I have been able to figure out
DynaValidatorForms
> and Validator.  Unfortunately I've encountered a problem with
retrieving
> request parameters after validation has occurred.
>
> Like lesson 3 in Rick's tutorial, I have a SetupMyFormAction in which
I
> prepopulate the form.  In this class I also set some supporting
request
> values, request.setAttribute("myattr", somevalue),  for the
corresponding
> JSP form page.  After validation I am forwarded back to my form but my
> supporting request parameters are no longer available.  I understand
why
> they would no longer exist but I am unsure as to where to reset these
> request values after validation.
>
> Vinh
>



-
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]



[newbie] Prepopulating a form

2003-03-19 Thread Johan Wasserman
Hi,
I need to populate a form from a StateBean (session) before displaying
it.
I cannot find anything to do it when using a FormBean (request) since
the bean is initialised when loading the form and no methods are
available to read the StateBean from the session (or so I think), any
suggestions will be welcome.
 
Thanks in advance.
 
Johan Wasserman
 


Populating FormBean at Get time?

2003-03-18 Thread Johan Wasserman
Hi,
Here's my situation;
I have a StateBean that keeps track of values for a certain JSP sequence
in my app.  The Actions of these JSP's populates the StateBean as part
of their workflow.
Question:
How do I get data back from the StateBean (session) into the FormBean
(request) when I GET the JSP.  In other words, one.jsp saved CompanyName
to the StateBean, in ten.jsp, I need to get the CompanyName from the
StateBean into TenFormBean and display it on ten.jsp
 
Thanks in advance,
Johan Wasserman
 


JSP's behind WEB-INF no access to img/scripts

2003-03-13 Thread Johan Wasserman
Hi, I have my JSP's behind WEB-INF, is there a way of mapping other
directories behind WEB-INF so that the images and scripts included on my
JSP's can be accessed from there as well.  It's OK having the JSP's
there to stop external forces from accessing them directly but now they
can still access my images and scripts directly.
 
Regards,
Johan Wasserman