Forums Register Login

bean methods are not working properly

+Pie Number of slices to send: Send
<%@ page import="java.util.*" %>
<HTML>
<HEAD>
<TITLE>STUDENTS DETAILS</TITLE>
</HEAD>
<BODY BGCOLOR="66FFFF">
<FORM ACTION="http://localhost:7070/sku/McaFinal" METHOD="POST">
<CENTER>
<FONT SIZE="4" FACE="Verdana" COLOR="DodgerBlue">
MASTER OF COMPUTER APPLICATIONS <P>
FINAL YEAR STUDENTS <P>
<% Object ia[]=((ArrayList)request.getAttribute("a1")).toArray(); %>
<% for (int i=0;i<ia.length;i++) { %>
<% out.println((CourseStudents) ia[i]).getStuname(); %>
<% out.println(ia[i]); %>
<% } %>
</CENTER>
</BODY>
</HTML>

in this code a1 is an arraylist sent from a servlet which is objects of a bean(CourseStudents). when iam writing comment for a red text iam getting the names of objects of bean like this...CourseStudents@15a6029 CourseStudents@5f6303 CourseStudents@5d9084 CourseStudents@bad8a8. upto now all are right. but how can i get the beans methods like getStuname and getStuno. please help me from this problem.

Thanks in advance.
please reply me

+Pie Number of slices to send: Send
You shouldn't use Java to iterate inside JSP. Have a look at JSTL's "<c:forEach>" tag which you can use to iterate the collection.
+Pie Number of slices to send: Send
Hi, Bandaru.

As 'Vijitha' said, we should not use Java to iterate inside JSP. There are better alternatives.

Try this, inside jsp instead of using scriptlets
use jsp expressions,
+Pie Number of slices to send: Send
Those are still scriptlets and should no longer be used in modern JSP pages. The EL should be used instead.
This is my favorite show. And this is my favorite tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 983 times.
Similar Threads
Display values form database
Keep getting NullPointerException
wrong jar reference
sequence of form information is not the same WHY???
how to retrieve the bean-objects of an arraylist in jsp
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 19, 2024 00:17:29.