Note that there are some explanatory texts on larger screens.

plurals
  1. POjava session bean - reload data?
    primarykey
    data
    text
    <p>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.</p> <p>OPTION 1: JSP1 - standard html form, submits to JSP2</p> <pre><code>&lt;form name="testform" method="post" action="jsp2.jsp"&gt; ... City: &lt;input name="currentCity" type="text" /&gt; </code></pre> <p>JSP2 - </p> <pre><code>&lt;jsp:useBean id="workorder" type="com.mycompany.app.WorkorderBean" class="com.mycompany.app.WorkorderBean" scope="request"&gt; &lt;jsp:setProperty name="workorder" property="*" /&gt; &lt;/jsp:useBean&gt; ... currentCity: ${workorder.currentCity} </code></pre> <p>Problem -when JSP2 submits to controller, and I call <code>WorkorderBean workorder = (WorkorderBean) request.getAttribute("workorder");</code> it returns null. So 'scope=request' doesn't make it from JSP to servlet.</p> <p>OPTION 2: Same scenario, but on JSP2 use 'scope=session'. <br/> <strong>Problem</strong>: 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. <br/><strong>Question</strong>: 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.</p> <p>OPTION 3: Have JSP1 submit to Servlet, which formats the session bean and sends to JSP2. <br/><strong>Problem</strong>: When user choose to go back from JSP2 to JSP1 to make changes, all data is lost in the form.</p> <p>How can I make this work?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload