Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

display all items from a list  RSS feed

 
mark smith
Ranch Hand
Posts: 258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

i have a javabean: Member
in a servlet i get all Membrer from a db...

request.getSession().setAttribute("beanID",memServ.findMember());

memServ.findMember() return a list

in the jsp page who to display all items?
i would like to see a couple of method to do it

<jsp:useBean id="beanID" scope="session" class="moreservlet.Member" />
<jsp:getProperty name="beanID" property="name" />

can display a name of a bean.... but for all bean... surely a loop is needed...

thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the JSTL <c:forEach> action.
 
mark smith
Ranch Hand
Posts: 258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok but does i need to use <jsp:useBean..../>

and without jstl?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66203
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. In a scriplet-free environment the utility of jsp:useBean is vastly diminished. It is only useful for the creation of bean instances that do not already exist in a variable scope. It is not needed in order to reference an existing scoped variable via the EL, only in scriptlets.

Without the JSTL, you either need to use a for loop in a scriptlet or some proprietary third-party tag library to loop over the collection.

In my opinion, not using the JSTL is nothing short of madness.
[ September 11, 2006: Message edited by: Bear Bibeault ]
 
mark smith
Ranch Hand
Posts: 258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in my database i have 10 data...


the data to retreive member info...

servlet info


jsp page


i see 10 times my last member....

surely a problem somewhere...
 
mark smith
Ranch Hand
Posts: 258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok just need to put the Member member =new Member inside the loop and not outside...
 
mark smith
Ranch Hand
Posts: 258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just need to try to do it with a scriptlet....
 
Stefan Evans
Bartender
Posts: 1836
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use this:

session.setAttribute("memberList", memServ.findMember());
The following should work

 
mark smith
Ranch Hand
Posts: 258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
work fine with JSTL

now i tried without....


servlet


my jsp


java process take 100% cpu
brownser spin, spin and display at the botton speed download (7M/second)
very strange.....
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!