Announcement Announcement Module
Collapse
No announcement yet.
RedirectView as POST Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • RedirectView as POST

    Hello

    Is it possible to send a redirect as POST and not as GET request?

    Thank's
    atsch

  • #2
    Not really, good point though.

    Comment


    • #3
      Hi ,
      Althought l knew that it cannot be send a redirect as POST , but sometime l found that there is a need to do it this way . l have a scenario which need to pass some parameters with POST ( hidden some of the critical parameters to display in the redirect url ) , and l don't know how your guys solve this problem (sorry for asking a not "spring" question , )?

      Thanks.

      moon

      Comment


      • #4
        Save the parameters in the user's session?

        Comment


        • #5
          hi martinl,
          Is this a prefer way or best practice ?

          l need this function because l am chaining controllers using SpingMVC (not SWF). l am implementing a borrow book function (a library automation system) and have the following scenario ,

          step 1. First display a screenA using parameterizableViewController , the screen contain just one input box to get the libraryUser's "cardNo" , which is a password like input box (the input cardNo cannot be seen by users),

          step 2. after input the cardNo , it will initialize a controller (controllerB , borrowFormController , a SimpleFormController) to display the libraryUser's loan details , screenB (FormView of controllerB), and the screen also include a input box for book's barcode input .

          step 3. After a successful borrow action in screenB (by input a book's barcode No.) , l hope to redirect the successful screen to the same page(screenB) , with updated loan details , so l need a cardNo parameter for controllerB to display the libraryUser's loan details (because l used a formBackingObject() to obtain a libraryUser Object which contain all the informations of libraryUser [l am using hibernate], include the loan details of the libraryUser - a collection property called borrows), l cannot use redirect here , because it will cause the cardNo to be display in the screenB's url.

          l thought of putting cardNo in the session before , but feel a bit strange, because we have to do it manually in controller and view to set and get the parameter "cardNo." ......hmm~~~~ , any body do it this way ? any downside ? can l have more suggestion or code snipplet to do it this way or other way ?

          moon

          Comment


          • #6
            I'm not an expert, but as far as I know - if you don't want to send the parameter in the querystring you would have to save it in the session (or in a class/instance variable, but then it would be shared by all users, and you probably wouldn't want that). I'm not experienced enough to tell what's a best practice and not.

            Comment


            • #7
              martinl; each "user", or more accurately each unique browser instance gets its own session.

              Storing the user details on the session is quite standard

              Comment


              • #8
                Originally posted by yatesco
                martinl; each "user", or more accurately each unique browser instance gets its own session.
                Doh! I knew that. What made you think I didn't? After all, I've been making web apps 6 years (though not Java all the time, and certainly not Spring).

                Comment


                • #9
                  apologies; I didn't quite get the meaning of
                  session (or in a class/instance variable, but then it would be shared by all users, and you probably wouldn't want that)
                  .

                  I missed the "class instance variable" bit

                  Comment


                  • #10

                    Comment


                    • #11
                      Re: RedirectView as POST

                      Originally posted by atsch
                      Hello

                      Is it possible to send a redirect as POST and not as GET request?

                      Thank's
                      atsch
                      Yes, using 307 response code and HTTP 1.1 compliant browser.
                      http://ppewww.ph.gla.ac.uk/%7Eflavel...-redirect.html

                      Comment


                      • #12
                        cool.

                        Didn't know that

                        Comment


                        • #13
                          Redirect View and Post

                          Originally posted by rector
                          Yes, using 307 response code and HTTP 1.1 compliant browser.
                          http://ppewww.ph.gla.ac.uk/%7Eflavel...-redirect.html
                          Is there a way we can use this with a redirect view?

                          Comment


                          • #14
                            A web framework "Stripes" claimed that it support "Redirect-after-Post"*.

                            Will spring support this feature in the near future ?

                            moon

                            *http://stripes.mc4j.org/confluence/d...ate+Management

                            Comment


                            • #15
                              Originally posted by yfmoan
                              A web framework "Stripes" claimed that it support "Redirect-after-Post"*.

                              Will spring support this feature in the near future ?

                              moon

                              *http://stripes.mc4j.org/confluence/d...ate+Management
                              Spring already "supports" this.

                              It is basically stating that after doing receiving a POST the server should not forward to a view, rather it should send a view that is a redirect to the view.

                              In plain English, if I have a view which allows users to enter details mapped to "/users/create.htm" and a success view mapped to "/users/created.htm" then the sequence of events should be:

                              - browser requests /users/create.htm
                              - user fills in details and submits a POST
                              - server creates the user and *sends a redirect* to /users/created.htm

                              It is the last point that is key. You can already do this in Spring

                              Comment

                              Working...
                              X