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

Continue reading

Add Date Picker to Java JSP

How to Add Java Date Picker

java_jsp_date_picker

Date Picker
Below steps for adding the Date Picker on Java using the Bootstrap and Maven, first add below dependency to the pom.xml

<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap-datepicker</artifactId>
<version>1.0.1</version>
</dependency>

Save or ctrl+s then Maven will download the webjar automatically, you need to restart the webserver either it's an embeded Tomcat or something else so the new dependency gets loaded.

Continue reading

How to format date in Java Spring JSP

How to format the date in the JSP ?
You need to add in the jsp a tag library which used for formatting which called JSTL format, below is the JSP "View" part:

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<fmt:formatDate pattern="dd-MM-yyyy" value="${project.projectStartdate}" />