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

JSP Include directives  RSS feed

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

I am a bit reluctant about my question but I would like to give it a try..

Are jsp:include directives still in used today in many modern web applications?

I have a menu that is being used across all jsp, i am not quite sure if putting them in a separate jsp and then including them in all my other jsp
would be better.

I was thinking of just copying the menu code in all jsp. This applies to footers and sidebars also.

Thanks..
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mark reyes wrote:I was thinking of just copying the menu code in all jsp. This applies to footers and sidebars also.


Why?

There are many mechanisms for sharing code across pages. Why resort to cut and paste?
  • include directive
  • include action
  • custom tag
  • tag file

  • For the kind of thing that you are talking about, I usually use a tag file.
     
    David Newton
    Author
    Rancher
    Posts: 12617
    IntelliJ IDE Ruby
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    mark reyes wrote:I was thinking of just copying the menu code in all jsp. This applies to footers and sidebars also.

    Wouldn't that mean you'd have to change it in every single page if the menu, footer, sidebar, etc. ever changed?!

    Also consider JSP templates.
     
    Mark Reyes
    Ranch Hand
    Posts: 426
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi David and Bear,

    Silly of me planning to do the cut and paste. Thats why I said I'm a bit reluctant of my question.

    For the kind of thing that you are talking about, I usually use a tag file


    I have been using only jsp:include and this is what I have known only for the time being. I have'nt thought of using a tag file for that matter.

    The correct question that I should have ask is what are other ways of including static/dynamic file in the response.

    P.S Bear,

    I own a copy of your book Jquery In action and actually have been applying it in my current project now. I am glad also I made the right choice.
    I just want to know, why not try writing a book about servlets and jsp...?
    With the way you manhandle the forums here, I do think you have a lot to share with the likes of me..
     
    Ben Souther
    Sheriff
    Posts: 13411
    Firefox Browser Redhat VI Editor
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    See the list that Bear posted earlier.

    There is an entry in the JSP FAQ that discusses the difference between the include action and the include directive.
    As Bear said, the newer tag files are a better choice for things like this.
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Posts: 65824
    134
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    mark reyes wrote:Bear, I own a copy of your book Jquery In action and actually have been applying it in my current project now. I am glad also I made the right choice.
    I just want to know, why not try writing a book about servlets and jsp...?
    With the way you manhandle the forums here, I do think you have a lot to share with the likes of me..

    Thanks for the kudos!

    I have, in fact, proposed a book on web application using JSP and servlets on a number of occasions, but no one is interested in publishing it. The consensus is that everything that needs to be written about JSP has already been written. I disagree -- I think a book focusing on modern practices and "putting it all together" would be useful. But alas, no takers.

    That said, I'm busy enough with current projects as it is.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!