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

Includes and imports can be messy

image with no caption

Using <jsp:include> or <c:import> lets you add reusable chunks of content, dynamically, to your pages. And you can even customize how the included file behaves by setting new request parameters that the included file can use.

Sure, it works fine. But should you really have to create new request parameters just to give the included file some customizing information?

Aren’t request parameters supposed to represent form data sent from the client as part of the request? While there might be good reasons to add or change request parameters in your app, using them to send something to the included file isn’t the cleanest approach.

Until JSP 2.0, there wasn’t a standard way to deploy included files—you could put the included pieces just about anywhere in the web app. And a JSP with a bunch of <jsp:include> or <c:import> tags isn’t the easiest thing to read. Wouldn’t it be better if the tag itself told you something about the thing being included? Wouldn’t it be nice to say something like:

<x:logoHeader> or <x:navBar>

You know where this is going...

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