O'Reilly logo

Head First Servlets and JSP, 2nd Edition by Bert Bates, Bryan Basham, Kathy Sierra

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

image with no caption
image with no caption

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required