Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Display a new view page with form after submit of a Jsp page in Spring

 
Ranch Hand
Posts: 49
Netbeans IDE Java ME Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my application i need to display new jsp page with form fields and all that rather than a normal success page.


I tried this code , it displaying the next page with fields but its not accessing the specified controller (On submit on page2 as well) .





But if try this code






its showing following exception :

Neither BindingResult nor plain target object for bean name 'frmPage2' available as request attribute.

I'm stuck here. Please someone guide me.


Thanks
Soumya





 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To your last question: It probably means you are trying to access this value 'frmPage2' somewhere else (possibly another controlelr or JSP). You renamed the model object to 'user', which is the name it's stored in the request (or session) as.

To your original issue, you say you can display the values but not access the specified controller? Let me see if I understand. You have something like the following:

page1.jsp ->Submit -> controller.onSubmit -> page2 (view w/frmPage2 as the model obj) -> page2.jsp (via view handler)

So far, so good? What controller can't you access? Is it the target controller from the page2 form?
 
Soumya Rout
Ranch Hand
Posts: 49
Netbeans IDE Java ME Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep you are right. Thats the exact flow. When the page2.jsp opens up it doesn't go to a different controller . Rather it access the same controller from it was called.

Now the problem i need to load some data in Bean object through formBackingObject method. But when the page2 loads up it directly comes without moving to the BackObejct method.. And on submit of the page2 it goes to earlier controller..


 
Mark Secrist
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you may have two problems. The typical pattern when returning a ModelAndView from a controller method is to resolve that view to a JSP (or some other view). Sometimes you need to do more processing or as you indicate, load a new form backing object. In that case you would put a redirect prefix on the view name. Something like:

Then your invocation path would be:
page1.jsp ->Submit -> controller.onSubmit -> redirect to controller2.formBackingObject() -> page2 (view w/frmPage2 as the model obj) -> page2.jsp (via view handler)

The other problem with page2 submit going to the same controller may have to do with the path you define for your action in the page2 form. It has to be a different path and that path has to be mapped to the new controller.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic