How to develop single page application using JSP?

1.3k views Asked by At

I want to develop an application using spring boot, jsp, bootstrap and hibernate. Where my each jsp page have the header, footer and left pane same but only the middle section get change based on the functionality. And i dont want to create each page with copying the same all over and even dont want impact application performance by adding all the UI dependencies in each and every JSP. So can someone please suggest me the best approach to deal with it.

I searched and find the Angular JS an react JS options, but I already have one application built in Spring 4, JSP, Hibernate technology stack and one which i have to develop is going to integrate with old one, so I think technology stack may impact the integration. For integration i am thinking about maven multimodule project.

Hence I need suggestion as i am in initial stages of development .

1

There are 1 answers

5
craigwor On BEST ANSWER

You make use of jsp:include; Here is one tutorial but I'm sure there's many others. https://www.roseindia.net/jsp/include-tag-jsp.shtml

Example:
<jsp:include page="includes/header.jsp" flush="true"> <jsp:param name="title" value="Example" /> </jsp:include>
header.jsp:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title>${ param.title }</title>
  <link rel="stylesheet" type="text/css" href="<c:url 
    value="/bootstrap/3.3.6/css/bootstrap.min.css"/>" />
</head>