Aside from the obvious mentions of setName being of void type, you're
missing a bunch of tags (HTML and JSP) on your form that are probably making
it very hard to troubleshoot the interaction between page and bean.
- Need an equal sign between VALUE and the actual value in the "sample"
field. Oughta be: VALUE=<%=TestBean...etc. Ditto on the Hallo and Huhu
fields. Also good form to put quotes around values in case they contain
spaces. Quotes make it more readable by separating all those gt's and lt's.
- Need a close HTML element on the end of that same input, right before the
line break.
- Need two close JSP scripts on Hallo and Huhu field before the close HTML
element.
------------
<BR>Enter new value :
<INPUT NAME="sample" VALUE="<%=TestBean.getName() %>"><BR>
<INPUT NAME="Hallo" VALUE="<%=setName %>">
<INPUT NAME="Huhu" VALUE="<%=TestBean.setName() %>">
------------
Yes, it looks ugly. That's HTML and JSP/ASP for ya. If your page displays
funny, it's always a good idea to look at the generated HTML for munched
tags/attributes before bothering to troubleshoot the logic.
The page still won't work quite right, since those setName invocations need
to be replaced with something that has a non-void return type.
Mike
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Charlotte Schaffstein
Sent: Thursday, October 19, 2000 9:16 AM
To: [EMAIL PROTECTED]
Subject: [JSP-INTEREST] JSP/BEAN
Importance: High
Hi everyone!
I need to solve this problem very fast:
JSP:
<HTML>
<HEAD>
<jsp:useBean id="TestBean" scope="session" class="test.TestBean"
/>
<jsp:setProperty name="TestBean" property="*" />
<TITLE>
Test
</TITLE>
</HEAD>
<BODY>
<H1>
JBuilder Generated JSP
</H1>
<FORM method="post">
<% String strr = TestBean.getName() %>
<% String strrr = TestBean.setName() %>
<BR>Enter new value : <INPUT NAME="sample"
VALUE<%=TestBean.getName() %><BR>
<INPUT NAME="Hallo" VALUE<%=setName() >
<INPUT NAME="Huhu" VALUE<%=TestBean.setName() >
<BR><BR>
<INPUT TYPE="SUBMIT" NAME="Submit" VALUE<%=TestBean.getName() %>>
<INPUT TYPE="RESET" VALUE<%=text1.TestBean.setName() %>>
<BR>
Value of Bean property is :<jsp:getProperty name="TestId"
property="sample" />
</FORM>
</BODY>
</HTML>
Bean:
package test;
public class TestBean {
private String sample = "Start value";
//JTextField text1;
//JTextField text2;
String name;
//Access sample property
//public TestBean()
//{
//this.text1 = new JTextField();
//this.text2 = new JTextField();
//}
public void setName(String nm)
{
//this.name = "Hallo";
this.name = nm;
}
public String getName()
{
//return "Huhu";
return this.name;
}
public String getSample() {
return sample;
}
//Access sample property
public void setSample(String newValue) {
if (newValue!=null) {
sample = newValue;
}
}
}
PLEASE HELP AND EXCUSE DOUBLE MAIL AS I HAD TO CHANGE MY SYSTEM
DATE IN BETWEEN!
Charlotte Schaffstein
[EMAIL PROTECTED]
===========================================================================
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