I am designing a small website using HTML + JSP.
This is my first time using JSP, though previously I have used PHP to make pages. One thing i found was that when i was making separate pages, i was copy + pasting the layout code of the site into each page, and then adding the content. This seems extremely inneficient, and I was wondering what is the most common practice for doing this?
One idea I had was to have a main index.jsp page that contains the layout code, and then use GET to pass a new page reuest to index.jsp. So to go to the “products” page you would type index.jsp?page=products, and a case statement in the index.jsp file would print the correct content.
I am a beginner in web design, so i would really appreciate any info or links on this topic.
A common (and simple) approach is to break your HTML up into commons sections (header, footer, sidebar, etc.). You then put these sections in their own .jsp file and include them on all pages:
That way if you ever need to modify one of the common sections, you only need to update the included .jsp, rather than all pages.