Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6882377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:14:44+00:00 2026-05-27T05:14:44+00:00

I have a situation as below: I have 2 web applications running on Tomcat.

  • 0

I have a situation as below:

I have 2 web applications running on Tomcat. Initially User gets logged in to the Application 1 and then. There is a link to the Application 2. On Clicking the link User should be redirected to second application.

Both applications using LDAP authentication.

Now, the problem here is second application has its own Authentication system.

So, We are planning to implicitly authenticate the user which is logged in the first system.

I have written a servlet, which gets executed when I click on link for App2 in the App1.

I am trying to use below code which should call Servlet “ldap-login” on app2 with given parameters.Parameter names are correct.

String targetURL = "http://localhost:8080/app2/ldap-login";

    HttpClient client = new HttpClient();

    PostMethod doPost = new PostMethod(targetURL);

    //doPost.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT_CONTINUE, true);
    doPost.addParameter("login_netid", "alice");
    doPost.addParameter("login_password", "alice");
    try {
        int status = client.executeMethod(doPost);
        if (status == HttpStatus.SC_OK) {
             // redirect
            response.sendRedirect("http://localhost:8080/app2/myPage");
        } else {
            System.out.println("Service failed, Response Code= " +                  
                HttpStatus.getStatusText(status));  
            System.out.println("Response Body --> " + doPost.getResponseBodyAsString());
        }
     } catch (Exception ex) {
         System.out.println("ERROR: " + 
         ex.getClass().getName() + " "+ ex.getMessage());
         ex.printStackTrace();
      } finally {
                doPost.releaseConnection();
      }

But I am getting Response “Moved temporarily”.

Can anyone suggest me any alternate ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:14:45+00:00Added an answer on May 27, 2026 at 5:14 am

    A 302 Moved Temporarily response is just a redirect. It’s exactly the kind of response which you would get when you do response.sendRedirect(). You can also very good get a redirect as a response to a successful login. I suggest to verify on the second application if it isn’t indeed redirecting when the login is successful. You should then check if the response code is 302 instead of 200. Or, alternatively, you need to tell HttpClient to follow any redirects automatically.

    Even more, if the login actually failed, what kind of response would you get from the second application? Would it throw an exception and thus return a response code of 500? Or would it just conditionally set some error message in the request scope and redisplay the JSP by a forward and thus keep a response code of 200? How would you then distinguish a 200 on a failed login from a 200 on a successful login?


    Unrelated to the concrete problem, your approach will likely not work if the second application does not share the same session as the first application. A login is usually stored in the session, but you’re not maintaining the session anywhere. Anyway, that’s subject for a new question 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have situation, where running a query that filters by an indexed column in
I have situation where a user can manipulate a large set of data (presented
I have situation like this: user submits form with action='/pay' in '/pay' I have
We have a situation where users are allowed to upload content, and then separately
I have a situation where I might have multiple instances of a program running
I have a web application. I'm configuring CI for it. We didn't use a
I have a tricky situation here. I have a web service written in C#
I have the below situation (say tblRecord) ID RowNum Data 1 1 and seventy
I have the below situation I have to match something like abc#(x,-12d) or abc#(x,-12d,
I have a situation where my DB tables are like below, I am wondering

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.