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

  • Home
  • SEARCH
  • 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 6012077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:21:07+00:00 2026-05-23T02:21:07+00:00

In the play framework documentation, there are two different ways to handle an action

  • 0

In the play framework documentation, there are two different ways to handle an action with validation errors :

  • Redirect to the index (validation section of the documentation) :
    if (validation.hasErrors()) {
        params.flash(); // add http parameters to the flash scope
        validation.keep();  // keep the errors for the next request
        index();
    }
  • Render to the form template (in the tutorial) :
    if (validation.hasErrors()) {
        render("@form", post);
    }

What is the best way to do this ? Render or redirect ?

  • 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-23T02:21:08+00:00Added an answer on May 23, 2026 at 2:21 am

    There are pros and cons for both approaches.

    My personal preference is to use the redirect approach, and the reason is that the browser URL correctly states where you are in the application. For example, if your index page calls the login action, if you don’t use redirects, then the browser URL will show login, when you are actually on the index page with errors.

    But, there is a problem with this approach. To achieve the redirect, and keep the validation error messages, you need to use validation.keep() and params.flash() (see this post here for details), so that the validation errors are kept for the next request. This is achieved behind the scenes by storing the validation errors and the user entered parameters in a Cookie (to ensure that Play remains stateless). As you are probably aware, the HTTP spec limits Cookies to 4Kb, so there is a risk that if you are entering data greater than 4Kb (which is possible for forms where you are entering big pieces of text), then your Cookie will overflow, and you will lose data.

    The original method that Play used was the redirect approach, but the second approach was specifically added to the documentation as a workaround because of the Cookie limit.

    A third, and a potentially cleaner option is to perform validation from the client side using javascript that envokes some serverside logic using AJAX. A sample of this can be seen in the 10th example of the samples-and-test/validation sample application.

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

Sidebar

Related Questions

I have started to play with xVal as my validation framework for an ASP.Net
I am new to play framework. tried to follow the tutorial http://www.playframework.org/documentation/1.2.4/guide2 when i
In play framework application.conf there are lines: %test.db.url=jdbc:h2:mem:play;MODE=MYSQL;LOCK_MODE=0 %test.jpa.ddl=create But I am using MongoDB
I have developed 2 applications with Play Framework, accessing different information, so it does
Play framework doesn't support the servlet specification, nevertheless among it's deployment options there's the
The Play framework documentation is kind of weak when it comes to module creation.
iam using AVFoundation Framework to play mp3 file ,everything works great ، i have
I am using the AVAudioPlayer framework, and I have several sounds that play one
I'm new to the Entities Framework, and am just starting to play around with
I am now learning on the audio framework of iphone. Just tried to play

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.