I am trying to send DTO Object from one jsp to another jsp using jsp:include tag. But it is always treating it as String. I can\'t able to use DTO in my included jsp file.
I don't think you really want tag files here. That's way overkill and too confusing for what you want to accomplish. You need to spend time understanding "scope". Instead of tag files, I would:
1) Change your attribute to be in the "request" scope instead of the default "page" scope by changing this line:
to this
That will make "attribute" a "requestScope" variable that can be used in other JSP files that are c:imported. (Note: forEach doesn't support scope attribute so use c:set to scope it inside each iteration.)
2) Change your original jsp:include to c:import. So change it from:
to this
Note that we don't explicitly try to pass the attribute as a parameter, because we have already made it available to all c:imported pages in the "requestScope".
3) Modify your c:imported JSP to reference the attribute using the requestScope by changing this:
to this
Here we no longer need the c:set because you already have the attribute available. We just need to make sure we look in the requestScope for that variable, instead of in the default pageScope or as a parameter (because we are no longer passing it as a parameter).
This technique will be a lot easier for you to manage.