Hello,
can someone please help me with the following problem?
I wrote a class testbean.java:
public class testbean {
private int age;
private String name;
public int getAge() {return age;}
public void setAge(int age) {this.age = age;}
public String getName() {return name;}
public void setName(String name) {this.name = name;}
}
<!--
And I got a JSP:
index.jsp
<html>
<head>
<title>Test</title>
</head>
<body>
<table border ="2">
<tr>
<td>Test</td>
<td><%@include file="global/test.jsp" %></td>
</tr>
<tr>
<td><%@include file="global/form.jsp" %></td>
</tr>
<tr>
<td>
<jsp:useBean id="test" class="testbean" />
<%= test.setName("Daniel") %>
<%= test.getName() %>
</td>
</tr>
</table>
</body>
</html>
-->
I use Tomcat as a server. Everytime I try to open the index.jsp I get an
error. Can someone please tell me how I have to call the bean in the jsp?
Thanks in advance.
Andi
Helio.es - 05 Nov 2003 18:45 GMT
| Hello,
Hello,
...
| public void setName(String name) {this.name = name;}
...
| <%= test.setName("Daniel") %>
....
test.setName("Daniel") return a void type. I think you need to replace
"<%=" with "<%".
The servlet code produced is like this:
System.out.println(test.setName("Daniel"));
And a function "System.out.println(void p)" not exist.
Bye!