Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to append query params in URL in case of input forward?
    primarykey
    data
    text
    <p>I am having trouble in maintaining the value of the query params which was sent in URL and lost during input forward due to validation error.</p> <p>I have a link link this </p> <pre><code>&lt;a href="/somelink/testpage?param1=value1&amp;param2=value2" id="test"&gt;Test&lt;/a&gt; </code></pre> <p>Clicking this link opens a new page which has a form with two hidden fields (which takes the value from these params). This page has two buttons <kbd>save</kbd> and <kbd>cancel</kbd>. My problem is</p> <ol> <li><p>I click the link, the input page corresponding to this action is <code>test.jsp</code>. This renders the page.(ex the URL is <code>https:host/somelink/testpage?param1=value1&amp;param2=value2</code>).</p></li> <li><p>I fill the form and click Save button which submits the form. In the Action class I get the params and set in request and do validation . Due to validation error, control goes to input page (but without query params in url). Now the input page has the error message and the URL is <code>https:host/somelink/testpage</code></p></li> <li><p>Now in the <code>test.jsp</code>, from the request the hidden fields in form are filled.</p></li> <li><p>The error is shown in the input page. Now if I click the save button again control goes to the Action class with form being submitted. In this case I can access those params (as form is submitted)</p></li> <li><p>But there is a case where in the input page with error, if the user presses <kbd>Enter</kbd> from address bar the request will go to action class (Remember when forward was done to the input page, the query params are not set in url, so now if request is sent there is no way to get the value of the param as its not in url and the form is not submitted.)</p></li> </ol> <p>Is there any way I can maintain the value of the params? I am not able to append it to URL as its a input forward. Only way I found to retain the values of params is add in session and get from session. But I am not sure if its advisable.</p>
    singulars
    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.
 

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