JAVA JSP Fragments, What is it? how to do it ?!?

What is JSP Fragments?

You created a navigation menu in one JSP and you don't want to repeat the code all over again and again in every single JSP, here comes the benefit of the JSP Fragments.

If you need to know how to create or add the navigation bar code, check the create Java navigation menu bar page.

Create a folder under src/main/webapp/WEB-INF/jsp/common and then start creating different files like:

  • footer.jspf
  • header.jspf
  • navigation.jspf

Copy all the navigation code and move it to navigation.jspf

Then move all code you need to be in the header which should be all taglib code and starting fromtill the firsttag and move it to the header.jspf

And last thing to do to copy all