• Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp:param vs c:param

 
Mark Garland
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In HFSJ page 452-453, it is shown how you can include/import pages and customise them using params.

The following code is used for the includes/imports:





My question is - what's the difference between the param tags (I understand the difference between import and include).
Are these tags interchangable? I'm guessing not - otherwise c:param shouldn't exist if it is just a duplicate, especially as jsp:param comes as standard.

Thanks in advance,

MG
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You use the one appropriate for the containing tag. jsp with jsp, c with c.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
c:param be nested in c:import, c:url and c:redirect. jsp:param is nested in jsp:include, jsp:forward, and jsp:params. They serve the same purpose, but cannot be interchanged.
 
Mark Garland
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I always get a little suspicious when I come across duplicate code that does the same thing.

Thank you both for your replies - it's definitely been cleared up, and its one more fact for the exam (now under a week away).

Thanks once again,
[ May 31, 2007: Message edited by: Mark Garland ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlets have changed very little since they first came out.

JSP, on the other hand, has undergone some drastic changes.
As a result it now has one of the major drawbacks that makes Perl code difficult to maintain; there are several syntaxes for doing the exact same thing.

The best rule of thumb is "Don't mix them".
If you're starting out a new project, learn the best practices for JSP 2.0.
Use MVC to factor everything but the presentation markup out of your JSPs into servlets and beans or plain old Java ojbects (POJOs) and then use JSTL and EL to perform any branching and looping needed to work with the result objects in your pages.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!