user1199657
user1199657

Reputation:

Redirect url to another application

I have an application with login Id and password. From this application, onclick of a certain menu item, I want to redirect to a different application which also has login Id and password.

I am trying to do this with session.setattribute but going nowhere.

Both the applications are built on Java EE using Struts and Hibernate. Can someone suggest how to do it?

Upvotes: 2

Views: 2197

Answers (3)

pap
pap

Reputation: 27614

What you are looking for here is what's called "Single Sign On", that is different applications sharing a users credentials between them so the user only has to log in once.

As you have already discovered, sessions are not shared between web applications. Indeed, there are no provisions in the Java Servlet specification for this. Depending on what application server you are using and your deployment architectyure, there are a number of proprietary solutions for this purpose. Simplest example is of you are using tomcat and all your applications are deployed to the same virtual host and realm (and using the same domain). Then you can use the single sign-on valve.

Upvotes: 1

Raul Rene
Raul Rene

Reputation: 10270

You cannot communicate directly through the HttpSession between 2 separate applications. What you need to do is use cookies in order to achieve this communication.

Also take a look at this thread, as yours seems to be a possible duplicate of that one.

Upvotes: 0

Vijay Shanker Dubey
Vijay Shanker Dubey

Reputation: 4418

As, your applications are deployed on the same domain, you can add a cookie with authentication token in the response and read the value of authentication token in the request in the other application.

Other option I can think of is, Create a Authenticated value and put it in database, and send the redirect request to other application with this value as a request parameter. Your other application can read that auth value and validate with database and let the user pass login and password page.

Upvotes: 1

Related Questions