Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Basic Bean Doubt

 
namrata suri
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am relatively new to the beans world. I have an action class where I am retrieving values from a database and putting the values in a bean which has 'n' no. of properties (since there are n columns per row of the db). Now I am putting these beans in an ArrayList and this list I am passing to a jsp where the values can be printed. Here are code snippets
I am not using DAO yet so please, do not refer to it.

jsp:



Here, the functions of the bean are visible and I do not want that. How can I use beans to solve the problem.

 
Mark Kiami
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
namrata suri wrote:
Here, the functions of the bean are visible and I do not want that. How can I use beans to solve the problem.


Hi,

Could you please clarify the question, do you mean the method of the EJB is visible in the JSP, and you don't want that? Could you post the code of the EJB?

For info you can use the <%= %> notation in the JSP, which is lighter than <% out.println(); %>

For example the following line

can be written:


 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35757
412
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
namrata suri wrote: I am not using DAO yet so please, do not refer to it.

I'm going to assume jobList is created in a servlet and just used in a JSP. If not, please look up the MVC pattern for why your JSP should not call an EJB or database directly.

Mark Kiami wrote:For info you can use the <%= %> notation in the JSP, which is lighter than <% out.println(); %>

Both of which are not recommended for new code. JSTL/EL is better because then you don't have any scriptlets in the JSP.
 
namrata suri
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya I do not want the get method to be visible in the jsp and jobList is an arraylist in the servlet which consists of several beans.

I tried using beans like this in my jsp



But, it says "cannot find property Key"....

Am I not writing the bean part correctly because, I checked on various sites and this is how they mentioned it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!