Solved

How to fix a JSP custom tag error ?

Posted on 2004-04-12
11
402 Views
Last Modified: 2013-11-24

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 !
0
Comment
Question by:sdesar
  • 6
  • 5
11 Comments
 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 10809961
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
 

Author Comment

by:sdesar
ID: 10815070
The .class and the .java file are  in /WEB_INF/classes/src/abtest/ExampleTag.class
0
 
LVL 13

Accepted Solution

by:
copyPasteGhost earned 50 total points
ID: 10818474
>>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
 

Author Comment

by:sdesar
ID: 10825351
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
 

Author Comment

by:sdesar
ID: 10825424
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 10825487
glad I can help,
thanks for the points,
ghost
0
 

Author Comment

by:sdesar
ID: 10825608
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
 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 10825631
use

out.println()

instead of
system.out.println()

anything else?
Ghost
0
 

Author Comment

by:sdesar
ID: 10826325
I get an error -
cannot resolve symbol
symbol : variable out
out.println(resultBuffer);

awaiting a reponse

Thanks again!
0
 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 10826397
well the out.println stuff can only be done in jsp

are we talking about jsp or java?
Gost
0
 

Author Comment

by:sdesar
ID: 10826538
Its in the Java function recurseNode()
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now