Hello
I am working under Win98, with Jswdk 1.0
I want try the followed communication
servlet
| |
V V
bean <-JSP
My servlet calls the bean, and the Jsp file
I want initialize from my servlet a value into my bean, then read this
value from my Jsp.
When I try to read this value from my Jsp, I get 0.
Do you have an experience about it.
Thanks in advance.
The code of my servlet:
import javax.servlet.*;
import javax.servlet.http.*;
import Test.*;
public class Servlet2Jsp extends HttpServlet {
public void doGet (HttpServletRequest request,
HttpServletResponse response) {
System.out.println("Initialization...");
BeanJsp beanJsp;
beanJsp = new BeanJsp();
beanJsp.setCount(30);
try {
// Set the attribute and Forward to hello.jsp
getServletConfig().getServletContext().getRequestDispatcher("/jsp/Test/Test.
jsp").forward(request,
response);
} catch (Exception ex) {
ex.printStackTrace ();
}
}
}
The code of my bean:
package Test;
import java.util.*;
public class BeanJsp {
private int count;
public BeanJsp() {
}
public BeanJsp(int count) {
this.count = count;
}
public void setCount(int count) {
this.count = count;
}
public int getCount() {
return this.count;
}
My Jsp file:
<html>
<body bgcolor="white">
<jsp:useBean id='test' scope='session' class='Test.BeanJsp'
type="Test.BeanJsp" />
ok
<BR>
Day of month: is <jsp:getProperty name="test" property="ResultCount"/>
<BR>
Day of month: is <jsp:getProperty name="test" property="ResultItem"/>
<BR>
Count: is <jsp:getProperty name="test" property="Count"/>
</body>
</html>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html