Meaningless Drivel is fun!
The moose likes JSP and the fly likes problem with tag files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "problem with tag files" Watch "problem with tag files" New topic

problem with tag files

maheedar sand
Ranch Hand

Joined: Feb 26, 2008
Posts: 36
I am practicing custom tag libraries in JSP. Please, check up the web application placed as attachment.

when we execute "forum.jsp" under pages folder it is not showing up any text placed under the variable "message". I checked with the book examples. They are working fine. what's wrong with my code. I'm not able to catch up. Please, help me.

source code of web application:

"forum.jsp" - this will be under pages folder

<%@ page contentType="text/html" %>
<%@ taglib prefix="c" uri="" %>
<%@ taglib prefix="my" tagdir="/WEB-INF/tags" %>

<%-- create test data --%>
<c:set var="message">
This is just a lot of text that the browser will format to fit the browser
window. Attempts to <blink> add HTML elements are dealt with by conversion
to character entities.
This part I want the browser to leave alone, so that all my indentations are
left intact:
public class Foo {
public String getBar() {
return bar;
And then some regular text again.
<title>Online Forum</title>
<body bgcolor="white">
<h1>Online Forum</h1>
Here's a formatted message:



"htmlFormat.tag" - tag file placed under "WEB-INF/tags" folder ( used for processing message in the above jsp page )

<%@ tag body-content="scriptless"%>
<%@ taglib prefix="fn" uri=""%>
<%@ taglib prefix="c" uri="" %>

<%-- capture the body evaluation result in a variable --%>
<jsp:doBody var="bodyRes"></jsp:doBody>

<%-- convert special characters to character entities --%>
<c:set var="escapedBody" value="${fn:escapeXml(bodyRes)}"></c:set>

<%-- replace "[cde][/cde]" with "<pre></pre>" --%>
<c:set var="convBody" value="${fn:replace(escapedBody, '[cde]', '<pre>')}"></c:set>
<c:set var="convBody" value="${fn:replace(convBody, '[/cde]', '</pre>')}"></c:set>

<%-- output the result --%>

rest of the application code is normal deployment descriptor with welcome file, no java class files.
Miku Ranjan
Ranch Hand

Joined: Oct 11, 2011
Posts: 98
You have not mentioned what is problem ?
Stefan Evans

Joined: Jul 06, 2005
Posts: 1580
Doesn't appear to be anything wrong with this code example.
Ran successfully in Tomcat 7.

Arvind Rao

Joined: Jun 24, 2011
Posts: 8

What exactly seems to be your problem?.

maheedar sand
Ranch Hand

Joined: Feb 26, 2008
Posts: 36
I don't know the problem but I tried using tomcat 5.0.8. It is unable to find the tadir location of "/WEB-INF/tags". I tried using tomcat 7. It is working fine. Thanks for the help.
maheedar sand
Ranch Hand

Joined: Feb 26, 2008
Posts: 36
sorry for the bit of confusion involved with me. Actually the text place in tags [cde]/[/cde] have to replaced with <pre>/</pre> but it is not in tomcat 5 so I tried using tomcat 7. It is working fine.
I agree. Here's the link:
subject: problem with tag files
It's not a secret anymore!