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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:07:05+00:00 2026-05-27T20:07:05+00:00

I have a JSP (AddDocument.jsp) with the following form: <form action= ${pageContext.request.contextPath}/project?to=submitAdd&idProject=${param.idProject} method=post name=form>

  • 0

I have a JSP (AddDocument.jsp) with the following form:

<form action=" ${pageContext.request.contextPath}/project?to=submitAdd&idProject=${param.idProject}" method="post" name="form">
    <div>Name:</div>
    <input type="text" name="name" /><br /> <br />
    <input type="submit" value="Add document" />
</form>

When submitted it calls a servlet (ProjectManager) which does the following:

private void addDocumento(HttpServletRequest request, HttpServletResponse response) {
    HttpSession session=request.getSession();
    // elaborating...
    session.setAttribute("addingResult", "Document added");
    // or error if an exception is caught
    redirect(request.getContextPath()+"/project?to=add&idProject="+idProject,request,response);
}

That is redirecting to the same page after setting a session’s attribute, which will be read by the JSP and shown to the user.
My problem is that this way the browser thinks it is going to a new page and its history increases (for instance, if I go to AddingDocument.jsp from X.jsp, insert 10 times an invalid name in the form and get redirected to the same page with an error, I will have to go back 10 times to arrive at X.jsp).
I want to be able to go back only 1 time to arrive at X.jsp, so I need some refreshing of my JSP instead of redirect, but with the same effect on request and response (that is no new submit if I manually refresh the page).
How can I do this?

  • 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-27T20:07:06+00:00Added an answer on May 27, 2026 at 8:07 pm

    You’ll want to use AJAX instead of a plain form submit. In addition to not contributing to the browser history, it should provide a “better” user experience that most users have come to expect today.

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

Sidebar

Related Questions

I have a JSP that is using Spring:form tags to bind controls to a
I have a JSP which has jQuery and wanted to change the action message
I have a .jsp page that the user loads directly. The request it with
I have many JSP files with EL expressions of the form ${foo.bar.baz.phleem1} , ${foo.bar.baz.phleem2}
I have a JSP page running on Tomcat 5.5. I have the following code:
I have a JSP Project, running on Tomcat locally and on Glassfish on the
I have a JSP program that displays a form where the user enters some
I am changing a GET to a POST. Currently I have .jsp?id=a,b,c,d. When changing
I have a jsp page with two radio tags. The page contains a struts2
I have a JSP which attaches a XSL to an XML document pulled from

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.