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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:41:47+00:00 2026-05-26T02:41:47+00:00

I have an issue with a JSP/Servlet set-up and what’s getting displayed in the

  • 0

I have an issue with a JSP/Servlet set-up and what’s getting displayed in the browser URL. page1.jsp submits to the servlet by a form with an action of “SAVE.do”. The servlet wants to pass a success message back to page1.jsp on the save. I do this by placing the message in the request using the

request.setAttribute("message", "Save Successful");

I then call

request.getRequestDispatcher("page1.jsp").forward(req,resp);

However, the browser will display the URL of http://localhost:8080/SAVE.do instead of http://localhost:8080/page1.jsp

When I change the forward to a redirect using

response.sendRedirect("page1.jsp");

Then the attribute is lost.

I guess I’m looking for the right way to do this, so that I can get the attribute back when page1.jsp loads again, WITH the right URL displaying in the browser.

  • 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-26T02:41:48+00:00Added an answer on May 26, 2026 at 2:41 am

    The right URL is the one the browser submitted to. The fact that the request is first handled by a servlet and then by a JSP is irrelevant to the browser. BTW, the JSP could very well be in a protected folder (like /WEB-INF), since the browser never sends a request to this JSP directly, but does through the URL of the dispatcher servlet.

    A redirect is a totally different thing than a forward. Forward means : I use another server component to finish the handling of my request. Redirect means : I have finished handling the request, and I’ll ask the browser to go visit another URL, and thus make a new request. This new URL could be a totally external URL (google.com for example).

    In your situation, you might want to apply the post-redirect-get pattern, so that a refresh of the “success” page doesn’t trigger the re-submission of the form. But if you want to display a dynamically chosen message, you’ll have to save it into the session and retrieve it in the second request. Your second request should go through a servlet as well, though, if you want to apply the MVC pattern correctly.

    Note that most MVC frameworks have suppport for the post-redirect-get pattern.

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

Sidebar

Related Questions

I have issue with: <form:checkboxes path=roles cssClass=checkbox items=${roleSelections} /> If previous line is used
I have an issue while getting the file name with out extension from a
I have an issue. I am getting data from a MySQL database, and make
If I have a servlet I am able to forward to a jsp in
I have this weird issue with special characters. In JSP, I am using field
I have a regular JSP/Servlet/Java web application that is used for uploading pictures from
I'm having an issue with a form. I have a button that when I
I have a jsp-page <%@page import=org.springframework.web.servlet.ModelAndView%> <%@page import=mvc3.helpers.Utils%> <%@ page language=java contentType=text/html; charset=UTF-8 pageEncoding=UTF-8%>
Here's my issue: I have a html form that after a user fills in
I have a servlet which takes data from the form and inserts it in

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.