Here Part2 is the JSP specific code that differs fron JSP to JSP
Part1 and Part3 are the common piece of codes that are same in all the JSPs, so here we are separating the codes Part1 and Part3, keeping them in two different JSP pages and including them in the main JSP page. Now this is working fine.
My 1st doubt is,
I want to keep Part1 and Part3 in a single file and include this at those places without affecting the functionality, can this be achieved?
Here while including the files in the JSP, in this case do i have to use the include directive(<%@include%>) or standard JSP include(<jsp:include>) ? Which one do i have to use?
Bharadwaj Adepu wrote:I want to keep Part1 and Part3 in a single file and include this at those places without affecting the functionality, can this be achieved?
Why do you wanna do that? Keep header(part1), footer(part3) in separate files. and develop body(part2) file for every page and include header and footer into them.
But I think you want header and footer in one file and want to include body dynamically. Is it? It would be ugly.
And IMO bear has suggested custom tag. but it's not worth the effort. You can create one custom tag with one attribute name file/page and pass the name of the file there. And rest of the things will be handled by custom tag. I would still suggest the first way.
Vishal Pandya wrote:And IMO bear has suggested custom tag. but it's not worth the effort. You can create one custom tag ...
So you say that creating a custom tag is "not worth the effort" and then suggest creating a custom tag? Ummm...
In any case, this is incredibly easy using a tag file to supply the common header and footer. Each page would then simply look like this:
Passing URLs to a tag would be incredibly burdensome and unnecessary.