Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to share a user-connection between two projects

 
Karl-Heinz Kott
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

i need some help,

I have two GWT-projects: "login" and "webapp".
The user has to logon to my server with his credentials. The login-project has one servlet class with several servlet methods. At initialization of the servlet the "init" method will be called:




The ServletContext object gets an attribute "currentConnections" to store a ConnectionPool object.
The ConnectionPool object stores the connection from the given user in a HashMap with the given SessionId:



The user will be directed to "webapp"-application...
--------------------------------------------------

In my "webapp"-project i try to retrieve this stored connection for the user:



The con is always == null !!!
I think the scope of ServletContext with his attribute is to restricted?!?
My sessionId is possibly also a different in the "login" and the "webapp"-application.

Is there a better solution to share a user-connection between two web-apps?

I appreciate any advice!
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all , Each web Application has got its own ServletContext , so storing in ServletContext isn't appropiate .
Share a user-connection between two web-apps?

By connection you mean Database connection or User session ??
 
Karl-Heinz Kott
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ravi Kiran Va,

i try to hold a database connection object in a connection pool
and share this object between this both apps.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i try to hold a database connection object in a connection pool
and share this object between this both apps.


First of all sorry for the late reply.

You should not hold the Database connection too long , and still if you want to continue then
I guess what you were doing is an internal Application ( used within some Organization and not more than 30 users accessing simultaneously) If this is the case you can proceed doing so .

Please answer me this ??
Why do you want to Pass Database Connection Object ?? rather than getting it from Connection pool ?? Is it possible for you to explain the Scenario ??

Thanks .
 
Karl-Heinz Kott
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess what you were doing is an internal Application ( used within some Organization and not more than 30 users accessing simultaneously) If this is the case you can proceed doing so .


Every user has his own account in DB, so every user should get his own connection.
It`s not intended to share one connection between two ore more users. Btw. security concept is controled by DB.
The connection will be aborted by DB after a certain time -> users will be prompted to logon again.

Why do you want to Pass Database Connection Object ?? rather than getting it from Connection pool ?? Is it possible for you to explain the Scenario ??


I need to store this database connection object because of my two projects. In my logon-project, the user authenticates himself -> con-object will be
stored in the connection pool. Afterwards i direct the user to the webapp-project with Window.open(url...).
Then the user can do some requests to server (using servlets). On server side the connection object must be taken out of the connection pool
to make a request to the DB.

Again: How can i store this connection in a global "container" (servlet-context?) to hold an take it from it?
 
Karl-Heinz Kott
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any ideas? Is there maybe a workaround?
I need a quick (and if so dirty) solution...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic