File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Repetative html code in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Repetative html code in jsp" Watch "Repetative html code in jsp" New topic
Author

Repetative html code in jsp

prajakta patil
Ranch Hand

Joined: Dec 11, 2005
Posts: 30
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

Joined: Jan 10, 2002
Posts: 61224
    
  66

If a tag is predominately markup, you'd be better off using tag files.
[ November 17, 2008: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
prajakta patil
Ranch Hand

Joined: Dec 11, 2005
Posts: 30
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

Joined: Jan 10, 2002
Posts: 61224
    
  66

I said tag file, not TLD file.
prajakta patil
Ranch Hand

Joined: Dec 11, 2005
Posts: 30
oh I got it, thank you very much!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Repetative html code in jsp