jsp:use bean tag is used to declare and used object using tag format in jsp page.
Bean object is declared using use:bean tag in jsp page. set:property tag is used to set the values and get:property tag used to get the values from bean object.
Scope for jsp:bean is set to request so that when a request is transfer to another page its also accessible there.
following is the list of important attributes of jsp:usebean tag ➡ id (name of the object) ➡ name (name of the fully qualified class name of bean) ➡ scope (application,request,session and page), default is page.
In this example bean values are set in process.jsp and then its transferred to welcome.jsp using request dispatcher. Welcome.jsp access the values get the values which were set in process.jsp page.
Summary of files used in this example ➡️ index.jsp (to accept client input) ➡️ process.jsp (to declare and set the values in bean) ➡️ UserBean.java (user bean POJO file) ➡️ welcome.jsp (welcome page to display)
✔️ jsp:useBean standard action tag is use to establish a connection between a jsp page and a java bean. ✔️ In web applications of java, jsp and java bean communication is required in the following two cases: 1️⃣In a real-time MVC project, a model class (business class) will set the data to a java bean and a jsp (view) will read the data from a bean and finally displays it on the browser. 2️⃣If multiple jsp pages need common java logic then it separates that java code into a bean and then we call the bean from jsp.
Video features the following: 👉 How to define Bean class in java 👉 How to use bean class in JSP scriplet 👉 How to use bean using jsp:useBean
It contains the following files 👉 Index.jsp 👉 process.jsp 👉 UserBean.java