This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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

Getting bean property values using jstl in jsp page

Peter van Nes

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

Joined: Feb 05, 2001
Posts: 17271

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.


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

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.


I agree. Here's the link:
subject: Getting bean property values using jstl in jsp page
It's not a secret anymore!