post-redirect-get

Post-Redirect-Get when passing data to the form?

戏子无情 提交于 2019-12-14 03:44:05
问题 I have several scenarios where a servlet needs to pass data to a form in a JSP from the retrieved records from the database. Currently, I'm storing this information in the request, using a RequestDispatcher to forward to the page, and all is well. However, this is not fitting with the PRG pattern (AFAIK), and of course means that refreshing of the resulting JSP means re-running of the servlet, which is undesirable. I could of course store these values in the session, but that would mean

htaccess redirect from specific urls on home page or on another page?

落爺英雄遲暮 提交于 2019-12-13 02:58:29
问题 I read over 20 posts, and I did not find a solution, so in my case I want to redirect https://example.com/search/ in home page or on another page, but i don't want to redirect https://example.com/search/?q=query Is this possible? I hope to have a solution. Thanks 回答1: You need to check at the beginning of you search script if the environment variable QUERY_STRING has an empty value. For instance, in Perl: if ($ENV{QUERY_STRING} eq '') { {print "Status: 307 Temporary Redirect\n"; print

POST/Redirect/GET with Error handling

▼魔方 西西 提交于 2019-12-12 02:24:07
问题 The reason for this post is that I am trying to avoid the "form re submission error" that most browsers give off when a form is refreshed. Take the following example: The user is on a page called signpetition.php and shown a basic HTML form: <div id="sign-errors" style="display: none;"> </div> <form action="" method="post"> <input type="submit" name="submit_button" value="sign petition" /> </form> So, the user clicks the submit button and now the POST data will be read and verified.

Post/Redirect/Get pattern in flask

二次信任 提交于 2019-12-11 07:30:45
问题 The view function of my toy app was: @app.route('/', methods=['GET', 'POST']) def index(): name = None form = NameForm() if form.validate_on_submit(): name = form.name.data form.name.data = '' return render_template('index.html', form=form, name=name) And it looks like this when I use PRG: @app.route('/', methods=['GET', 'POST']) def index(): form = NameForm() if form.validate_on_submit(): session['name'] = form.name.data return redirect(url_for('index')) return render_template('index.html',

JSF2 PRG and Validation Error

≡放荡痞女 提交于 2019-12-10 20:48:57
问题 I haven't still found a definitive implementation of PRG pattern with JSF2. The BalusC blog presents a very good solution, but as the author himself states, such a solution does not apply for JSF2. The solutions based on Flash scope work fine if no validations error occurs, but in case of validation error the REDIRECT is not executed because the lifecycle does not call the NavigationHandler. Assuming that pages are not cached by the browser (setting the right headers in the HTTP response), if

Chrome history bug maybe - doing PRG, and when navigating again to the same form - no history entry is added

隐身守侯 提交于 2019-12-10 12:57:11
问题 There is a strange back button behavior occurring only in Chrome. I have two pages - Grid and a Form the scenario: 1. When navigating from the Grid to the Form everything is fine - the Grid is added to the history. 2. When the Form is sent to the server via post, i use RedirectToAction to redirect(302) to the Grid again - the Form is added to the history. 3. When navigating again from the Grid to the Form after the redirect, a history point containing the Grid address is not added to the

ZF2 fileprg with files in collection

流过昼夜 提交于 2019-12-10 11:27:31
问题 I can't get fileprg plugin to work with the files in a collection. I am trying to upload multiple files using FormCollections , but in $form->getData() there is no key related to my collection or the files . I tested the form and fileprg with simple file input (in the same form) and it worked uploaded/renamed and it was in the $form->getData() . what am i missing ? is there anything special to be done with the collections to get it to work ? 回答1: In the file \Zend\Mvc\Controller\Plugin

Is there a name for the PRG pattern that doesn't redirect on failed validation?

主宰稳场 提交于 2019-12-10 05:20:04
问题 My website follows the Post-Redirect-Get pattern. There seems to be 2 ways to deal with failed validation. Either: Render the page with validation messages Temporarily store the validation messages, and redirect to a GET that shows the messages Do both of these implementations follow the PRG pattern? Is there a more specific way to describe either of these patterns? I am asking primarily for educational sake. 回答1: Since no one has answered, I'm going to suggest my own answer. PRG Strict means

How to prevent duplicate entries while refreshing?

筅森魡賤 提交于 2019-12-08 23:56:51
问题 I have an index.jsp page where I have a form where the user enters some data that gets stored in the database using a Controller servlet. I want to display the same page ( index.jsp ) with that form after entering the data in the database. Also, I want to display all the entries that the user entered in the database. I tried using the forward() method of RequestDispatcher . It works fine (meaning I am able to display that same form again and also display all the data entered by that user

After logout back/reload issue in Struts 2

随声附和 提交于 2019-12-08 21:42:33
I have a login page ( Index.jsp ) , here user put user id and password. on submit LoginAuthentification.java (action class) called and authenticate the user , but according to the result in action class it return the JSP. <action name="login" class="com.struts2.LoginAuthentication" method="execute"> <interceptor-ref name="clear-cache" /> <result name="manager">/ManagerView.jsp</result> <result name="SSE" type="redirectAction"> <param name="actionName">viewPlan</param> <param name="userID">${userID}</param> </result> <result name="input">/Index.jsp</result> <result name="error">/error.jsp<