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 Navigation Bar to Java Spring [Maven]

Add Navigation Bar to Java Spring [Maven]

Add navigation bar to your Spring Java project [Maven], start by adding something similar to the below example snipit

Just place below code inside the  tag.

<pre><code><nav role="navigation" class="navbar navbar-default">
<div class="">
<a href="" class="navbar-brand">dotsway blog -- your daily information gate</a>
<div class="navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="/login">HomePage</a></li>
<li><a href="/link-page">Link</a></li>


That's it ! now you have a navigation menu, but then you need to place the above code in all pages, instead you can use JSP fragments which will help you not to repeat the code but have a header JSP , footer...etc, to read about JSP Fragments click here.

Failed to convert property value of type java.lang.String to required type java.util.Date

Today while adding to Java file a text box of date, i got below error while updating it:

Failed to convert property value of type java.lang.String to required type java.util.Date

The problem here that Spring cannot put the data into object and cannot map it's format, the solution is to bind it to format you want to use.

A data binder is needed, what is that ? how it's implemented ? let me answer those questions in the coming few lines.

If you have a date in a format like "mm-dd-yyyy" then it needs to be parsed, either you will do it manually after the @RequestParam Date or you will use like below or even using the WebDataBinder like Ex#2:
Continue reading

Add Date Picker to Java JSP

How to Add Java 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


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=""%>
<fmt:formatDate pattern="dd-MM-yyyy" value="${project.projectStartdate}" />