Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSTL Shawn Bayern question...  RSS feed

 
Harpartap Singh
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a question for Shawn Bayern....
The JSTL core library has the following tags:
<c:import>, <c:redirect>.
How come there is NO <c:forward>? I am assuming that <c:import> is a dynamic include functionality, so why not a dynamic <c:forward>?
thanks,
/hs
 
Shawn Bayern
Author
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good question.
Note that JSP already supports a <jsp:forward> tag. The only potential advantage of JSTL including its own <c:forward> tag would be that you could use the JSTL expression language with it. This might sound like a valid reason, but as of JSP 2.0, the standard <jsp:forward> tag will begin to support the expression language anyway.
(If JSTL 1.0 introduced a <c:forward> tag, we'd have to leave it in for future versions, even though it would just overlap with <jsp:forward> beginning with JSP 2.0.)
 
Harpartap Singh
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But, I thought another advantage of using <c:import> was that you are not bound to "relative URL" anymore.
So if there was a [B]<c:forward>[B] we could forward requests to another web application's URL without having to go through the circus of getContext, getRequestDispatcher, forward etc.
Isn't convenience a motivation for JSTL?
 
Shawn Bayern
Author
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Harpartap Singh:
But, I thought another advantage of using <c:import> was that you are not bound to "relative URL" anymore.
So if there was a [B]<c:forward>[B] we could forward requests to another web application's URL without having to go through the circus of getContext, getRequestDispatcher, forward etc.
Isn't convenience a motivation for JSTL?

It's a judgment call. That would be the only motivation for a <c:forward> tag, and cross-context imports and forwards aren't necessarily even supported by all containers. (It's effectively an optional feature.) With the <c:import> tag, we get the benefit of imports from absolute URLs, as well as cross-context inclusions; this wouldn't apply to <c:forward>. Effectively, the decision implies that the JSTL group thinks the combination of <jsp:forward> and <c:redirect> is enough for most people. Still, a <c:forward> tag could always be added in the future (or <jsp:forward> modified) to support cross-context forwards.
Convenience is indeed a motivation, but as with any spec, you have to pick your battles carefully because (a) time is limited and (b) extra features mean more learning for new users.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!