Setting a request attribute works... but only for the JSP to which you forwarded the request
With the beer app, it made sense to store the model info for the client’s request in the request object, because the next step was to forward the request to the JSP responsible for creating the view. Since that JSP needed the model data and the data was relevant to only that particular request, everything was fine.
But that doesn’t help us with the email address, because we might need to use it from all over the application! There is a way to have a servlet read the init parameters and then store them in a place other parts of the app could use, but then we’d have to know which servlet would always run first when the app is deployed, and any changes to the web app could break the whole thing. No, that won’t do either.


Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access