Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

calling object function from jsp

843836Nov 17 2004 — edited Nov 17 2004
Hi,

I'm making a webapp which has to show a list of topics, when you click on a topic it shows a list of comments made to the topic.

The list of topics is shown as a table with 2 columns, Title and Last Post.

Showing the title is no problem as it is just a field in the Topic class, but to display the Last Post I have to call a function that iterates through a list of comments and select the most recent post made.

As u can see in the following jsp, im trying to call the function of the object topic like this.. ${topic.getLastMessage()}, when I do this it results in the following error.. The function getLastMessage must be used with a prefix when a default namespace is not specified

I read something about making your own taglib to do this but it seems rather strange a function call on an object cant be done through reflection, but retrieving values can.

Anybody got an idea how to solve this?
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<html>
<head>
	<title>Topic list</title>
</head
<body>
	<h2>Topic List</h2>
	<table cellspacing="0" width="50%" border="1">
		<tr bgcolor="#99CCFF"><td><b>Subject</b></td><td><b>Last post</b></td></tr>
		<c:forEach var="topic" items="${sessionScope.topiclist}">
 			<tr>
	 			<td><a href="./message/do?operation=select&id=${topic.id}">${topic.subject}</a></td>
	 			<td>${topic.getLastMessage()}</td>
 			</tr>
		</c:forEach> 
	</table>
	<br>
	<a href="./topic/do?operation=newtopic">New Topic</a>
</body>
</html>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 15 2004
Added on Nov 17 2004
2 comments
269 views