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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:59:05+00:00 2026-05-17T17:59:05+00:00

Here’s what I want to do. It seems simple, but I can’t get it

  • 0

Here’s what I want to do. It seems simple, but I can’t get it to work. JSP1 – user fills out form, submits to JSP2. JSP2 populates the form values in a Bean and displays data, and offers user option to return and modify (history.back()), or submit to Servlet. I’ve come up with three different options, and each has problems.

OPTION 1: JSP1 – standard html form, submits to JSP2

<form name="testform" method="post" action="jsp2.jsp">
...
City: <input name="currentCity" type="text" />

JSP2 –

<jsp:useBean id="workorder" type="com.mycompany.app.WorkorderBean" class="com.mycompany.app.WorkorderBean" scope="request">
    <jsp:setProperty name="workorder" property="*" />
</jsp:useBean>
...
currentCity: ${workorder.currentCity}

Problem -when JSP2 submits to controller, and I call WorkorderBean workorder = (WorkorderBean) request.getAttribute("workorder"); it returns null. So ‘scope=request’ doesn’t make it from JSP to servlet.

OPTION 2: Same scenario, but on JSP2 use ‘scope=session’.
Problem: when the user chooses to go back to JSP1 and modify data, then re-submits to JSP2, JSP2 does not use the new values, because it already has the bean as a session bean.

Question: Is there a way I can clear out the session bean when I submit from JSP1? I don’t think I can do this with Javascript.

OPTION 3: Have JSP1 submit to Servlet, which formats the session bean and sends to JSP2.

Problem: When user choose to go back from JSP2 to JSP1 to make changes, all data is lost in the form.

How can I make this work?

  • 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-17T17:59:05+00:00Added an answer on May 17, 2026 at 5:59 pm

    Possible solution for option 1:

    In JSP2 put the request parameters in hidden form fields so that they can be submitted to your servlet. In the servlet you have to read the request parameters manually. But you need no session and you can go back from JSP2 to JSP1, change some values, submit to JSP2 again. Then a submit on JSP2 transfers the changed values to the servlet.

    Update:

    In your second option: The reason why the bean properties remains unchanged after a resubmit is, that you placed the jsp:setProperty Tag inside of jsp:useBean. With this constellation jsp:setProperty is only called at bean creation. During the second call of JSP2 the bean workorderalready exists in the session scope and no jsp:setProperty call happens.

    You can change that behaviour if you place the jsp:setProperty Tag outside of jsp:useBean:

    <jsp:useBean id="workorder" type="com.mycompany.app.WorkorderBean"
       class="com.mycompany.app.WorkorderBean" scope="session" />
    <jsp:setProperty name="workorder" property="*" />  
    

    Then jsp:setProperty will be called at every JSP2 call and overwrite the bean properties with the request parameters.

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

Sidebar

Related Questions

Here is my HTML. Just a simple form: <form> Username: <input type=text id=username/> <br/>
Here is the code: create table `team`.`User`( `UserID` bigint NOT NULL AUTO_INCREMENT , `Username`
Here is my work environment: Eclipse Juno as IDE with maven2 plugin on it
Here is what I am currently doing. PHP echo's out the recent post in
Here's my search array: $aExt = array('png','jpg','gif'); I want to search through the variable:
Here is what I want to do. Use this HTML line and have the
Here's what I'm doing. I want to upload multipart file via Ajax to my
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Here's a problem I ran into recently. I have attributes strings of the form
Here is my code, which takes two version identifiers in the form 1, 5,

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.