This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes JSP and the fly likes How can I include jsp file which contains jsp and jstl tags in the custom tag? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "How can I include jsp file which contains jsp and jstl tags in the custom tag?" Watch "How can I include jsp file which contains jsp and jstl tags in the custom tag?" New topic
Author

How can I include jsp file which contains jsp and jstl tags in the custom tag?

Alex Indus
Greenhorn

Joined: Jun 01, 2012
Posts: 6
Is it possible to include .jsp file which contains jstl tags in the custom tag class which extends TagSupport(using tag files isn't an option in my particular case)? I need to create a custom tag to draw a table with the content of page scope variable. Table rows will change according to the attributes of the tag. I have created jsp file with the table but I have no idea how to include it in my tag. Calling pageContext.include() just put the code from jsp into html without any compilation=(
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61310
    
  66

What did you name the include file? An include should process the included JSP.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Alex Indus
Greenhorn

Joined: Jun 01, 2012
Posts: 6
table.jspf

custom tag this tag just prints all code from table.jsp to the html page without any transformation(
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61310
    
  66

A .jspf file is not a JSP. It's a JSP fragment and is only suitable for use with the include directive.

Rename the file with the .jsp file type.
Alex Indus
Greenhorn

Joined: Jun 01, 2012
Posts: 6
Thank you! I just renamed table.jspf in .jsp, and imported jstl =) I have one more question - can this table get access to the page scope variables of the page where my custom tag is used&
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61310
    
  66

No. Place scoped variables that need to be shared in request scope.

By the way, is there a reason that all of this isn't a good use case for a tag file?
Alex Indus
Greenhorn

Joined: Jun 01, 2012
Posts: 6
I have a task to do this using tag class which extends TagSupport. Do you think using tag files make the code simpler?
 
GeeCON Prague 2014
 
subject: How can I include jsp file which contains jsp and jstl tags in the custom tag?