Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / JavaBeans / November 2003

Tip: Looking for answers? Try searching our database.

beans & JSP

Thread view: 
Andreas Köhler - 05 Nov 2003 17:09 GMT
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!


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.