• 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Basic Bean Doubt

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:


 
author & internet detective
Posts: 42056
926
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
New rule: no elephants at the chess tournament. Tiny ads are still okay.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic