wood burning stoves
The moose likes Servlets and the fly likes servlet Connection from one application to other Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet Connection from one application to other" Watch "servlet Connection from one application to other" New topic

servlet Connection from one application to other

Viplav rao

Joined: May 23, 2008
Posts: 3
Hi all,

This is my first post on this forum. I am confused and with no clue while I am posting this query. I am writing an web application in which I have the requirement to redirect to other web application(running on a different server), but the problem is after redirecting I have to login to the other application and go to a specific page in that application(everything without user knowledge) from where uses continues his normal transaction.

For example:

Let test1 and test2 are applications. test2 has authentication procedure in it. If user is in test1 application where he clicks a link he has to go to a page in test2 application and after that he can browse the test2 application as if he logged in to the test2 application. Is this possible.

I looked at the requestdispatcher class but I think it is for redirecting in same application. response.redirect() is just forwarding to a page. I cant put authetication credentails in it. Any help is appreciated.

Thanking you

Viplav Kallepu
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Do you have the ability to alter the application on the other server?
[ May 24, 2008: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Viplav rao

Joined: May 23, 2008
Posts: 3
Thanks for the reply..
Yes, I have the ability(but with giving appropriate user credentials..) to alter the application running on the other server.just to reiterate What I need is a functionality like
send.Redirect() and then setting the session values needed for the redirected page so that from there the user can continue.Any kind of suggestions are appreciated...
Johnson Abraham

Joined: May 31, 2004
Posts: 19
Well, if you have know how the authentication works in the Test2 application then it is fairly straight forward.

You said there is a link in the application1 which takes you to the application2. Then you can try either of the below mentioned ways

1. Have a HTML form in the page and assign the URL of the application2 to its action attribute i.e. form action. Have the number of hidden textboxes in the page which are prepopulated with the authentication credentials, say username and password. On the click of the link call a javascript which will submit the form.

2. Else assign the application2 url to the href of the link and append the login credentials to it. For example

Although second bullet is a way to do it, its not at all secure as you will be exposing the credetential in the link.

I hope this might help you.

Viplav rao

Joined: May 23, 2008
Posts: 3
Thank you for the help.. I think it will work for single page and with basic authentication.. but what I need to do is I have to login to the server then I have to go to the required page. I googled for this, but I wasn't able to get the information. I believe some thing similar to the webRequest in .NET (screenscrapper) will suffice the requirement..please correct me If I am wrong

The authentication type I wish to use is digest authentication..so I need to encrypt the username and password and then login and then go to the required page..Is it possible..

Any sort of help is great ..
I agree. Here's the link: http://aspose.com/file-tools
subject: servlet Connection from one application to other
It's not a secret anymore!