File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Repetative html code in jsp

 
prajakta patil
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have some block of html code (includes some jstl tags...tables...td�) in one jsp page and that block of code get repeated in that jsp page. That code is of around 100 lines. It got repeated for four times so that it takes 400 lines extra. I am thinking to use custom tags. But I don�t know how to include that html block of code in the dostarttag method of java class which implements Tag interface. Or is there any other way to handle this situation?

Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a tag is predominately markup, you'd be better off using tag files.
[ November 17, 2008: Message edited by: Bear Bibeault ]
 
prajakta patil
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but where to include that mrkup language in TLD file? suppose my TLD file contains following code:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">

<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>DemoTags</shortname>
<uri>http://www.stardeveloper.com</uri>
<info>Demo Tags Library</info>

<tag>
<name>firsttag</name>
<tagclass>com.stardeveloper.tag.test.FirstTag</tagclass>
<bodycontent>empty</bodycontent>
<info>Your first JSP Tag</info>

<attribute>
<name>listname</name>
<required>true</required>
</attribute>
</tag>
</taglib>


and block of html code:
<table>
<c:forEach var="it" items="${listx}">
<tr><td>...
....
</c:forEach>


whenever this block will get repeated, listx will have different value but remaining code will remain same throughtout the jsp pages. so that I am planning to send listx value through custom tag. now please tell me whe should i write this block of code in tag file?

thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I said tag file, not TLD file.
 
prajakta patil
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh I got it, thank you very much!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic