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

bean methods are not working properly  RSS feed

 
bandaru Babu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%@ 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

 
Vijitha Kumara
Saloon Keeper
Posts: 3998
42
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Chinmaya Chowdary
Ranch Hand
Posts: 437
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66205
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Those are still scriptlets and should no longer be used in modern JSP pages. The EL should be used instead.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!