In your servlet, use request.setAttribute as follows
request.setAttribute("myStation", value);
where the value is the object you want to read later.
and extract it later to another servlet / jsp using request.getAttribute as
String value = (String)request.getAttribute("myStation")
or
<%= request.getAttribute("myStation")%>
Note that the scope of get / setAttribute is limited in nature - attributes are reset between requests. If you intend to store values ββfor longer, you should use the context of the session or application, or rather the database.
Attributes differ from parameters in that the client never sets the attributes. Attributes are more or less used by developers to transfer state from one servlet / JSP to another. Therefore, you should use getParameter (no setParameter) to retrieve data from the request, set attributes if necessary using setAttribute, internally forward the request using RequestDispatcher, and retrieve attributes using getAttribute.
Vineet reynolds
source share