Sorry this is a bit off topic, but I am not aware of a servlet-interest
mailing list (if there is one..please direct me to it).

I happen to have a rather odd need to allow separate web apps (Servlet 2.2
specifically) to share one particular object. On our site our users can be
in one of 3 possible contexts, lets say A, B or C. But on our admin site, we
need to allow our admin folks access to all 3 context at the same time.
Normally I was doing this by having them log into each one via a context of
/A/login, /B/login and /C/login, each time creating the context (web app)
and the session object needed to confirm they are logged in. What I am
trying to achieve is the ability to use a single login entry point that
creates all 3 contexts at one time, so that when they switch between any of
the three, the login process in not required again..the /A, /B and /C
sessions for that client already exist. I will eventually need this
functionality for our main site as well. Part of this reasoning is due to
using one browser to access all 3 contexts. Because of the use of cookies,
if you open up MSIE and access the same www page using A, B or C, under one
context, it messes things up. You log in to A in one window, and B in
another, then navigate around B a bit. When you go back to A, because the
one client has one session existing on the server, and the session data says
"I am in B" since that is where they last did something, when the user goes
to the window with A logged in, and clicks a link..on the server its stored
them as being on B, so the page that comes back now is B. Its a bit
confusing. We use colors on our site. A = orange. B = green and C = blue.
Imagine logging in to A and getting an Orange screen of links. Then you log
in to B in a different window and see green background with links. Click
around a bit and everything remains Green. Now go back to the A (orange)
browser window and click. The page you get back now has Green background and
links because the session variable used to track your location indicates you
are in B instead of A.

To solve this, at least for our Admin folks, by moving to Servlet 2.2 I can
separate each session into 3 by using the web-app setup with separate
contexts. So I decided I would have a single "index" page that lists all the
links. On that page they click A, B or C and it changes that one pages color
to orange, green or blue respecitively and on the server a session is
created that stores the location they are in. To allow two or more windows
to work with A, B and C all at the same time (for example, they are pulling
up a clients info which is stored in each of the types (A, B and C) and they
need all 3 viewable at one time ) I use 3 separate contexts. Now comes the
problem of logging in. When the user firsts logs in, a session is created
not in A, B or C, but in the "root" app. But the links on that main page
have a /A /B or /C as part of them to indicate the context to use (to allow
sessions to exist for one client in more than one section (A, B or C) for
this link. The problem is that during the login process I need a way to
create the "main" session (which works now) as well as the /A, /B and /C
contexts session objects all at one time. What I have so far is inside the
login method, after login is successful, I create 3 URL objects, one to /A,
/B and /C. Each one points to a special servlet so the path is like
http://xxx.xxx.xxx.xxx/A/CreatContextServlet/ and so on with A becoming B
and C. Thus, it sort of "fakes" the login process to A, B and C so that when
an admin user goes to do something in A and B, the contexts are already
created and the object that I use to determine if a user is an "admin"
capable person (and also used to see if they are logged in or not) exists.
The problem I am having now is how to pass an object to each of these
contexts. The MAIN context is created (again..its not A, B or C..but a 4th
one..the MAIN one). When the admin user logs in, the ClientSession object is
created and stored in the http session of the root app. I want to create the
3 contexts AND put this object in all 3 of these contexts sessions so that
the code that checks on every page if the user is an Admin person or not,
functions properly.

Phew! This is hard to explain. I hope I have made some progress in making it
easy enough to understand. I am sorry for the lengthy repeated explanation
but I really can't explain it any other way.

Worst case scenario, I can just call the Login process on all 3 contexts
from within the main login method (using URL objects) passing to the login
process the login name and password. I would rather not do that because it
requires 3 more hits to the database, but if that is what it takes..that is
what I'll do.

Lastly, can anyone explain the use of URL and URLConnection. I read the API
but I haven't found any resources that explain how to use it. I will play
with it a bit more. So far I just do a URL url = new
URL("http://xxx.xxx.xxx.xxx/A/CreatContext");  url.openConnection(); and
thats it. Do I need to close the connection? Do I have to call anything else
to "activate" the CreateContext servlet for A, B and C?

Thanks.

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to