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

  • Home
  • SEARCH
  • 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 3221766
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:54:51+00:00 2026-05-17T15:54:51+00:00

I am having a weird problem here, and I am really stuck, need to

  • 0

I am having a weird problem here, and I am really stuck, need to get this work badly.

so i have a page say index.jsp with a link say “a href=servlet?action=viewMenu”. when I click on this link it will go to doGet() on my servlet and here is the code in my servlet.

 protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
                 String action = request.getParameter("action");
                   if(action.equals("viewMenu")){
                        address = "/viewAdminMenu.jsp";
                   }
                RequestDispatcher dispatcher = request.getRequestDispatcher(address);
                dispatcher.forward(request,response);
     }

So the above code works fine but after request forwarding, my browser shows the url as

localhost/project/servlet?action=viewMenu. (with http:// in the beginning)

I don’t want the above url as I could not set the basic authentication with tomcat, what I need is

localhost/project/viewAdminMenu.jsp (with http:// in the beginning)

I have tried to find information about this but haven’t been able to figure it out.

Any help will be very much appreciated.

  • 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-17T15:54:51+00:00Added an answer on May 17, 2026 at 3:54 pm

    If you want the browser to go to a different URL, you’ll need to tell it to redirect, rather than doing a forward in the server. See the sendRedirect() method of HttpServletResponse.

    Forward

    • a forward is performed internally by the servlet
    • the browser is completely unaware that it has taken place, so its original URL remains intact
    • any browser reload of the resulting page will simple repeat the original request, with the original URL

    Redirect

    • a redirect is a two step process, where the web application instructs the browser to fetch a second URL, which differs from the original
    • a browser reload of the second URL will not repeat the original request, but will rather fetch the second URL
    • redirect is marginally slower than a forward, since it requires two browser requests, not one
    • objects placed in the original request scope are not available to the second request

    (From Java Practices.)

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

Sidebar

Related Questions

This is a really weird problem that I have been having. When I download
This is a weird problem I have started having recently. My team is developing
I'm new to Ruby, so I'm having some trouble understanding this weird exception problem
I'm having an extremely weird problem with a PHP script of mine. I'm uploading
I'm having some weird issues with Xcode, and this is pretty much impossible to
I'm having a weird issue with Visual Studio 2008. Every time I fire it
Having a heckuva time with this one, though I feel I'm missing something obvious.
Having been a PHP developer on LAMP servers for quite a while, is there
Having worked with Classic ASP for about 2 years now by creating a few
Having read the threads Is SqlCommand.Dispose enough? and Closing and Disposing a WCF Service

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.