File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes Getting bean property values using jstl in jsp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Getting bean property values using jstl in jsp page" Watch "Getting bean property values using jstl in jsp page" New topic
Author

Getting bean property values using jstl in jsp page

Peter van Nes
Greenhorn

Joined: Jun 09, 2010
Posts: 29
Hi, I am a Spring newbie and have the assignment to explore a framework in about 10 days for my Java certification. My choice was Spring which was not the easiest choice i think.
Because i also have to show a working demo, i try to build the application simultaneous my theory reading. So already my apologies if i am making wrong statements, use incorrect terms, etc.

I currently have build a simple application with one controller. The application allows the user to fill in a complaint, enter the way he/she wants to get informed about the process and finally receives a initial e-mail or sms depending on the entered choice. The application uses the following bean in the applicationContext.xml to select the valid class for sending the message.



In the klachtView.jsp (welcome page) shown below i want to list the key values of the klachtService bean defined in applicationContext.xml. If this is possible, what should i to correct this, because currently this gives an 'Neither BindingResult nor plain target object for bean name 'klachtService' available as request attribute' at line 84 where the bind is done.

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

anything you want to display in a jsp page, you just have to include it into the Model that you make/return from your controller. It can be anything. But unless it is in your model or HttpSession or other Web objects, then you won't have access to it. The Web page has no idea about your Application Context, nor should it.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Peter van Nes
Greenhorn

Joined: Jun 09, 2010
Posts: 29
Hi Mark,

Thanks for the reply. I did know that it had to be in the model somehow, like using any other servlet. But had no clue how to implement it in a Spring 2 framework application. In my controller i only had the onSubmit method, the only method i had worked with. This method is not executed when the initial get of the page is done. I finally found the formBackingObject method wherein i create a new instance of my object. I add some default property values here by reading the properties of bean defined in my applicationContext.xml.


Cheers,
Peter


 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Getting bean property values using jstl in jsp page