Hi!,
 
    Here is an example that i experimented with.....
 
the JSP code....
<%@ page import="hello.NameHandler" %>
<jsp:useBean id="mybean" scope="page"
class="hello.NameHandler" />
<jsp:setProperty name="mybean" property="*" />
<html>
<head><title>Hello, User</title></head>
<body bgcolor="#ffffff" background="background.gif">
<%@ include file="dukebanner.html" %>
<table border="0" width="700">
<tr>
<td width="150"> &nbsp; </td>
<td width="550">
<h1>My name is Duke. What’s yours?</h1>
</td>
</tr>
<tr>
<td width="150" &nbsp; </td>
<td width="550">
<form method="get">
<input type="text" name="username" size="25">
<br>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</td>
</tr>
</form>
</table>
<%
if ( request.getParameter("username") != null ) {
%>
<%@ include file="response.jsp" %>
<%
}
%>
</body>
</html>
 
the other JSP response.jsp.....
<table border="0" width="700">
<tr>
<td width="150"> &nbsp; </td>
<td width="550">
<h1>Hello, <jsp:getProperty name="mybean"
property="username" />!
</h1>
</td>
</tr>
</table>
 
 
the bean......
 
package hello;
public class NameHandler {
private String username;
public NameHandler() {
username = null;
}
public void setUsername( String name ) {
username = name;
}
public String getUsername() {
return username;
}
}
 
This is an example straight from the JSWDK....i hope this helps...
 
 
Senthil.
 
-----Original Message-----
From: D.Sankara Narayana <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Wednesday, October 13, 1999 5:42 AM
Subject: How to use BEANS IN JSP

Dear Friends,
 
I have recently started using jsp.
 
My html form is invoking a servlet. In the servlet I made an object of bean class and set the properties. In the jsp I tried to get those properties for dynamic web content.
 
Kindly help me out with a small example.
 
Regards,
Shankar.

Reply via email to