Pr.Pg Next Pg

JSP useBean Program tutorials

 

Simple bean program used in useBean tag of JSP

Sam Sir

//Program name Bean.java
//Simple bean program used in useBean tag of JSP package mybean;

public class Bean {

String str;

public String getStr() {

return str;

}

public void setStr(String str) {

this.str = str;

}

}

 

 

 

 

 

JSP program to show how to use useBean tag and this program will use Bean.java bean

Sam Sir

<%-- index004.jsp --%>

<%-- JSP program to show how to use useBean tag --%>

<%@page language="java" import="mybean.Bean" contentType="text/html"

pageEncoding="UTF-8"%>

 

<html>

<head>

<title>JSP useBean Action Example</title>

</head>

<body>

<center><h3>useBean Demo</h3></center>

<jsp:useBean id="useBean" class="mybean.Bean">

<jsp:setProperty name="useBean" property="str" value="Welcome Beans!" />

</jsp:useBean>

<p><jsp:getProperty name="useBean" property="str" /></p>

</body>

</html>

Output

Jsp UseBean

Pr.Pg border                                              Next Pg