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 7966907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:33:30+00:00 2026-06-04T06:33:30+00:00

I am working on a project where I have running servlets packaged in a

  • 0

I am working on a project where I have running servlets packaged in a war that listen for requests and populate a foreign div on a separate page. An initial request is made to servlet (a) and if there is data to display, it renders that HTML. If there is NO data, it passes a query string to another servlet to handle the request and then renders a page with options to choose.

I am running Tomcat 6 with Windows Server 2008.

But I run into two problems:

  1. When I use redirect, I get no response from the servlet being
    redirected to. I have some javascript alerts up that are never called by the (b)
    servlet. I AM using relative paths and confirm the link is
    correct in logs.
  2. When I copy that link in step 1 in a new window, I see
    the results. Just not when it’s embedded in another page that makes
    the request. Why would that be? Is it possibly a limitation from the host page and not being able to render the response?
  3. When I use a forward, I see the servlet response,
    but then a new window opens. Thus taking the person away from the
    original page. This would be great if the results render in the same page.

What’s the best practice to assure that I can “redirect” from an initial servlet call to another servlet using the response object from that first servlet?

  • 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-06-04T06:33:32+00:00Added an answer on June 4, 2026 at 6:33 am

    A redirect returns a HTTP 302 response with the new URL in Location header which the client needs to deal with. Basically, your JS code must check the response status code if it’s 302 and then extract the Location header and then re-send a new request on it. Repeat this until the response status code is 200.

    That it works when pasting the URL in browser’s address bar is because the browser already knows how to deal with 3nn responses properly. If you open up the network traffic tracker in browser’s webdeveloper toolset, then you’ll see that a second GET request is been fired on the new URL.

    Another way, if the servlets run in the same container, is to just use RequestDispatcher#forward() instead of HttpServletResponse#sendRedirect().

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

Sidebar

Related Questions

I'm working in a project that already have a build process running with maven
I have a fully working Setup project within Visual Studio 2008 that takes inputs
I am working on a project in netbeans that requires the running project to
I have been working on a project where I have a Worker class that
I'm currently working on a project running on JBoss AS 7 that requires authentication
I'm working on a streaming project. I have VLC running as a server, streaming
I'm working on an Azure based project for some research and have been running
I'm currently working on a project in c# where I have a service running
I have been working on a Android project, that is intended to be compatible
I working on project and have problem with threading and update of UI. I

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.