O.K. It works. But if I use <jsp:setProperty name="h" property="User" value="new user" /> It doesn't work again. The error said: javax.servlet.ServletException: Can't find method for User But if I use <% h.setUser("new user") %>, it works. Is it a bug ? or somethins wrong in jsp:setProperty tag ? Thanx Best Wishes Yen-Ju <html> <head><title>Counter 7</title></head> <body> <h1>This is a counter </h1> <jsp:useBean id = "h" class = "test.Count8" /> <h4> Users: <jsp:getProperty name="h" property="User" />. <br> </h4> </body> </html> Brian Lee wrote: > It looks like your problem is that you never initialize your user String. > Try using private "String user = null;" or "String user = "";" > > BAL > > -----Original Message----- > From: yjchen [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, March 29, 2000 7:57 AM > To: [EMAIL PROTECTED] > Subject: How can I use String between JSP and JavaBean > > Hello, > > I try to use JavaBean to set and get a String type, but it always goes > wrong. > The code is below: > > JavaBean: > > package test; > > public class Count8 { > private String user ; > > public Count8() { > } > > public String getUser() { > return user; > } > > public void setUser(String user) { > this.user = user; > } > } > > and the JSP: > > <html> > <head><title></title></head> > <body> > <jsp:useBean id = "h" class = "test.Count8" /> > <h4> Users: <%= h.getUser() %>. <br> > </h4> > </body> > </html> > > If I change user into int type, everything is O.K. > Why can I use string between JavaBean and JSP ? > How can I solve this problem ? > > Thanx very much > > Best Wishes > > Yen-Ju > > =========================================================================== > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff > JSP-INTEREST". > Some relevant FAQs on JSP/Servlets can be found at: > > http://java.sun.com/products/jsp/faq.html > http://www.esperanto.org.nz/jsp/jspfaq.html > http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP > http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets