Once you define this class, compile it and place it in the class path of the network server. This server also needs to define a special directory to place bean classes. If you are using Blazix, you can place them in the "classes" directory. If you must change the class path and the server is running, the network server must be stopped and restarted.
Next let's modify "SaveName. jsp" to use bean to collect data:
<Jsp: useBean id = "user" class = "UserData" scope = "session"/>
<Jsp: setProperty name = "user" property = "*"/>
<HTML>
<BODY>
<A href = "NextPage. jsp"> Continue </A>
</BODY>
</HTML>
Here all we need to do is add a jsp: useBean flag and jsp: setProperty flag. This useBean flag is used to find the "UserData" instance in the session. If an instance is found, it will update the old instance. If the instance is not found, it will create a new UserData instance (the UserData instance is called bean ), then place it in the session. The setProperty flag automatically collects the input data, matches the bean method name, and places the data in the bean.
Next, modify NextPage. jsp to retrieve data from bean:
<Jsp: useBean id = "user" class = "UserData" scope = "session"/>
<HTML>
<BODY>
You entered <BR>
Name: <% = user. getUsername () %> <BR>
Email: <% = user. getEmail () %> <BR>
Age: <% = user. getAge () %> <BR>
</BODY>
</HTML>
Note that the useBean label is reused. This bean is used as a variable of the class "UserData. Data typed by the user is collected in the bean. We can ignore savename.jsp”, and the goal of getname.html is "NextPage. jsp", and the data is equally valid as long as we add a jsp: setProperty flag. In the next tutorial, we will use SaveName. jsp as an error handling and automatically connect to NextPage. jsp. In other words, it will ask the user to correct the error data.
In this tutorial, the secondary exercise is as follows: A) Compile a jsp/HTML file so that you can enter the name of the System property and A System. getProperty value is displayed. B) return to the boolean variable we modified manually. Instead of using the boolean variable, set the variable from the HIDDEN form area to true or false.