How to fix a JSP custom tag error ?


What does this error mean and how to fix it --


org.apache.jasper.JasperException: /ExampleTag.jsp(8,7) Unable to load tag handler class "coreservlets.tags.ExampleTag" for tag "csajsp:example"

I am trying to simulate this example -  " Simple Example " - tag that outputs data to a JSP
http://shrek.wccnet.edu/~chasselb/java278/ClassNotes/jspTags/basics.htm


Awaiting a response !
sdesarAsked:
Who is Participating?
 
copyPasteGhostCommented:
>>The .class and the .java file are  in /WEB_INF/classes/src/abtest/ExampleTag.class

I think that might be wrong..
/WEB_INF/classes/abtest/ExampleTag.class

also what's your package
Ghost
0
 
copyPasteGhostCommented:
do you have the .class files in the right place..

the must be under "web-inf" in a "classes" folder
do you know what I mean?
Ghost
0
 
sdesarAuthor Commented:
The .class and the .java file are  in /WEB_INF/classes/src/abtest/ExampleTag.class
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
sdesarAuthor Commented:
This is what i have in the ExampleTag.java
package coreservlets.tags;

import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;

/** Very simple JSP tag that just inserts a string
 *  ("Custom tag example...") into the output.
 *  The actual name of the tag is not defined here;
 *  that is given by the Tag Library Descriptor (TLD)
 *  file that is referenced by the taglib directive
 *  in the JSP file.
 *  
 */

public class ExampleTag extends TagSupport {
  public int doStartTag() {
    try {
      JspWriter out = pageContext.getOut();
      out.print("Custom tag example " +
                "(coreservlets.tags.ExampleTag)");
    } catch(IOException ioe) {
      System.out.println("Error in ExampleTag: " + ioe);
    }
    return(SKIP_BODY);
  }
}

0
 
sdesarAuthor Commented:
OOPs I got it I put the above .java file in a dir called coreservlets/tags
that fixed it !
Thanks
here are your excellent points!
0
 
copyPasteGhostCommented:
glad I can help,
thanks for the points,
ghost
0
 
sdesarAuthor Commented:
Also, this test was to see how to output the data from a funstion I wrote.  Currently all the data is being outputted to the catalina.out logs.
Would you please advise on how to change the code below to output the data to the JSP itself --

here is the code

//Jsp Code

 <%@ page import = "src.abtest.*"
  import="java.util.*"
 
%>

<%@ taglib uri="taglib_tree.tld" prefix="tree" %>




<%
 ProjectNode projectNode=null;

projectNode= BmxServletUtilities.getProject(session);
JSPProperties JP = new JSPProperties();
String treeString = JP.recurseNode(projectNode, 0);
%>
<a href="http://www"> hello! </a>
<tree:createTree treePicture="tree.gif" nodePicture="leaf.gif" openPicture="open.gif" dhtml="true">
<%= treeString %>
</tree:createTree>

<BR>End Here




//Java Code


public String recurseNode(DbNode thisNode, int level) {
        final int maxLevel = 4;
        final StringBuffer resultBuffer = new StringBuffer();
        final NodeClassFilter filter = new NodeClassFilter();
        filter.accept(DefaultNode.class);
        filter.reject(SystemFolderNode.class);
        filter.reject(SystemFileNode.class);
        filter.reject(HistoryContainerNode.class);
        filter.reject(DeletedItemsFolderNode.class);
         // DbNode dbnode=(DbNode)thisNode.findNode(path);
        System.out.println("I am in recurseNode");
        // System.out.println("Node is: " + thisNode.getDisplayName());

        //DO STUFF HERE
        if (level == maxLevel) {
            //print out <tree with link

            // in JSP the tree tag looks like the comment below
            //<tree:addNode code='<%="<a href=\\"http://www.yahoo.com\\">"+hChildNode.getName()+"</a>"%>'/>

            System.out.println("if loop");
           resultBuffer.append("<tree:addNode code='<%=\"<a href=http://www.yahoo.com\">");
           try {
                resultBuffer.append(thisNode.getName());
           } catch (CommandFailedException cfe) {
                Log.write(cfe);
           }
           resultBuffer.append("</a>%>'/>");
            System.out.println(resultBuffer);
        } else {
            //print without link
             System.out.println("else loop");
            resultBuffer.append("<tree:addNode code='");
            try {
                resultBuffer.append(thisNode.getName());
            } catch (CommandFailedException cfe) {
                Log.write(cfe);
            }

            resultBuffer.append("'>");
            System.out.println(resultBuffer);
        }
        synchronized (thisNode) {
            try {
                if ((thisNode.getChildCount() > 1) && (level < maxLevel)) {
                    final Enumeration thisNodeChildren = thisNode.children();
                    while (thisNodeChildren.hasMoreElements()) {
                        final Node thisNodeChild = (Node)(thisNodeChildren.nextElement());
                          System.out.println("I am in synchronized recurseNode");
                        if ((thisNodeChild instanceof DbNode) && (filter.accept(thisNode))) {
                            resultBuffer.append(recurseNode((DbNode)thisNodeChild, level+1));
                        }  // end inner if
                    }  // end while
                }  // end outer if
                 System.out.println("end tag");
               resultBuffer.append("</tree:addNode>");
           //      System.out.println(resultBuffer);
                return resultBuffer.toString();
            } catch (CommandFailedException cfe) {
                net.common.Log.write(cfe);
                return null;
            }
        }  // synchronized
    }  // end recurseNode


Eagerly awaiting a response!

Thanks!
0
 
copyPasteGhostCommented:
use

out.println()

instead of
system.out.println()

anything else?
Ghost
0
 
sdesarAuthor Commented:
I get an error -
cannot resolve symbol
symbol : variable out
out.println(resultBuffer);

awaiting a reponse

Thanks again!
0
 
copyPasteGhostCommented:
well the out.println stuff can only be done in jsp

are we talking about jsp or java?
Gost
0
 
sdesarAuthor Commented:
Its in the Java function recurseNode()
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.