• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to retrieve the bean-objects of an arraylist in jsp

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<%@ page import="java.util.*" %>
<HTML>
<HEAD>
<TITLE>STUDENTS DETAILS</TITLE>
</HEAD>
<BODY BGCOLOR="66FFFF">
<CENTER>
<FONT SIZE="4" FACE="Verdana" COLOR="DodgerBlue">
MASTER OF COMPUTER APPLICATIONS <P>FINAL YEAR STUDENTS <P>

<% Object a2[]=((ArrayList)request.getAttribute("a1")).toArray(); %>
<TABLE BORDER="1" BGCOLOR="LightSalmon">
<% for (int i=0;i<a2.length;i++) { %>
<tr><td><% out.print((CourseStudents)(a2[i]).getStuname()); %>
</td><td><% out.print((CourseStudents)(a2[i]).getStuno()); %></td></tr>
<% } %>
</table>
</CENTER>
</BODY>
</HTML>


hi everybody
in my program CourseStudents is name of bean. in my servlet program i added these bean objects into an arraylist and send it to
this jsp. please help me how to retrieve the objects of a bean from arraylist and how to show the results in jsp.

hanks in advance
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the button on your post.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Firstly, scriptlets are discredited. You should be using the JSTL and EL in your pages.

Secondly, you never explained what problems you are having with the existing code.

Finally, your code is rather a mess. You use different casing for the HTML throughout, which (in addition to not using code tags for display) makes your code hard to read. Making your code easy to read is a first step in getting quality help.
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi bandaru,
Please use code tags when posting code here. And look for JSP standard actions, EL (Expression Language) expressions and JSTL. Those when used together all your java code (scriptlets, scriptlet expressions, scriptlet declarations) in the JSP can be eliminated.
 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use EL for this, have a look at this: http://java.sun.com/products/jsp/reference/techart/unifiedEL.html (2005 article but I think it's useful)
Look carefully to the JSTL <c:forEach tag you will see that does exactly what you need in that JSP.
 
reply
    Bookmark Topic Watch Topic
  • New Topic