Besides request, you can also use session.
In the JSP you can define the scope of a
java bean. This scope may be "page" (default value), "request", "session", "application".
I always use request and session.
What's the difference between request and session ?
A request can be compared with going to a bar, asking for a beer and paying it when you get it. The bartender doesn't have to keep in mind that you have to pay.
A session is going to a restaurant and eating � la carte. You demand a salad for starters, a main dish, a dessert and a
coffee. And after that, you pay. The session starts with you demanding the salad and ends with you paying the bill.
SO you have a choice. If you can forget about the values as soon as you've showed the values of the java bean on a HTML page, use request. If you want to keep in mind what the user did during his visit on your web site, use session.
When using request,
you should write
request.setAttribute("mybean", mybean)
And in the JSP you have
<jsp:useBean id="mybean" class="org.gertcuppens.general.MyBean" scope="request"/>
when using session you should write
HttpSession session = request.getSession(true); // if you didn't have a session in the request
or
HttpSession session = request.getSession(false) ; // if you already have put a session in the request and merely wants to add something to it
session.setAttribute("myBean", myBean);
And the JSP can read this value by
<jsp:useBean id="myBean" class="org.gertcuppens.general.MyBean" scope="session"/>