In my web application I got Header.jsp file which contains default header contents. Im including it in all other pages using jsp:include tag inside body tag of each individual p
It's not a good solution but it will absolutely work.
People usually answer these questions in theory, like "no, because it's not valid by the standards". That's right, it's not. Future browsers might not support it, some source parsers may get confused, HR/IT experts checking out your portfolio may think you know less than Jon Snow, and all sorts of bad things. In theory. But it does happen out there in the real world, and browsers are not stupid: they know what you mean, they will take both head tags and work as expected.
And it's not just by chance.
They have very good reasons:
1. Head tag is optional. (see notes below the article!)
Browsers accept headtag-like contents even outside it, so in effect they ignore the tag itself completely. And if they ignore one, they will probably ignore several, too.
2. Visitors are precious.
Browsers want you to enjoy your time. They want to show you the best possible page they can compose out of the mess they've got. It's their intention, they want to show you that the internet works, not teach you how bad your favorite website is. If they can find out what the html code wants to express (and there's no deadly ambiguity in the structure), they will do their best to fix the page.
3. Bad markup tolerance is a thing.
Browsers are not just patient and forgiving, but sometimes they do acrobatic moves to get your stuff working. Look at this horrible mess:
See this text?
With the background AND color properly set?
Your browser's quite a badass.
About browser tolerance, here's a lot more with super-ugly examples - make sure you forget everything you've seen when you're back!)
So yes, of course, the principle is "be a good friend of your browser", no matter how cleverly it fixes your mistakes. But if you wake up in a dark dungeon with hungry lions around and your only way out is using two
tags - well, don't hesitate! It's not broken syntax, it's not a serious violation of HTML5 rules - it's no more than a convenient cheat. And don't fall for the widespread myth that non-standard, non-tidy sites prosper a lot worse: people usually just don't know for sure and want to stay on the safe side. Typically they are the ones who describe hell as a place where validator-failing web authors go.TLDR: In practice, two head tags work.
Now please have only one if possible.
ADDITIONAL NOTES
As @StanislavBerkov pointed out, both W3C and MDN suggests that the HEAD tag is implied, meaning it's probably better to just leave the head
tag entirely. I would not recommend this approach if you have the standard option of using only one of it, but having none is apparently better than having two. The documentation is not very clear around the topic so make sure you test everything in the major browsers - but again, in practice, you'll face no issues.