Web Development

General discussion


Overcome jsp:include limitations

By Mark W. Kaelin Editor ·
Tell us what you think about our tip on overcoming jsp:include limitations with the JSTL import tag.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

Avoiding jsp:include

by kparks In reply to Overcome jsp:include limi ...

I've avoided using jsp:include and opted for an in-house written "http include" style in our jsp base classes. But, I'm still not sure about jslt for the simple fact that I don't want the "View" layer to be too heavy.

Collapse -

Shades of #include in C/C++

by stephen mcconnell In reply to Avoiding jsp:include

This smacks of the #include found in C/C++. Is this where we want to be going in JSP's?

Collapse -

erm yes

by bayard In reply to Shades of #include in C/C ...

in answer to where we want JSPs to go, I would
normally envision some form of including being at the
heart of most web sites.

It's the perfect way to apply a theme to a system without
going the whole hog to a content management system
that pieces together pages on the fly.

I could see an argument for having 'typed' includes, like
a tag for 'header', a tag for 'footer' with special abilities,
but to lose the concept of including seems like a big

Maybe I'm misunderstanding.

Collapse -

fated to happen

by bayard In reply to Avoiding jsp:include

While I am not against your feelings that the view layer
could get too heavy, it seems that the JSP spec is going
in this direction. JSTL will either roll into the JSP spec
someday or become a tight sibling, always found in the
same place.
If you're just looking for an improved include, ie)
matching your internal ones, then you can just use that
aspect of jstl when the time comes. Admittedly at the
moment it would be an addition of a new library, so I
would advise against leaping to it, but instead keep an
eye out and prepare for JSP 2.0 so you can deprecate/
modify your in-house stuff accordingly.

Collapse -

But can I nest variables?

by Noosh In reply to Overcome jsp:include limi ...

Does this handle variable scoping any better than jsp:include? I'd love to be able to use included .jsp snippets as methods for outputting particular kinds of data, for example one that takes a class "Employee" object and formats it in a standard way. Right now all I can do is the equivalent of "x=thisData; include employee.jsp", i.e. using global variables. Takes me back to BASIC programming.

outputs lists as alternating white/grey rows where I pass in the data in an array

Collapse -

Am I missing something...

by talkingstone In reply to But can I nest variables?

Have you considered using: <jsp:param name="username" value="jsmith" /> to pass parameters? note that the xml style jsp include allows you to add dynamic (<%= %&gt values to any number of listed parameters.

I may be winging it with this suggestion as it's been some time since I tried this.


Collapse -


by bayard In reply to Am I missing something...

My view exactly. jsp:param appears to be all this reader
needs. JSTL has the param syntax and so matches
jsp:param at least. I need to check up to see if there are
any advantages in the spec beyond jsp:param. Mainly
as I can't recall if jsp:param is limited to Strings or not.

Related Discussions

Related Forums