O
O
Oleg Gamega2014-08-15 16:02:55
Java
Oleg Gamega, 2014-08-15 16:02:55

Unable to load tag handler class what's wrong?

Good day.
Quite a stupid question at the Hello World level, previously I wrote only for android and a little detscope.
There is a class

public class HelloWorld extends TagSupport {
    private static final long serialVersionUID = 1L;

    @Override
    public int doStartTag() throws JspException {
        try {
            pageContext.getOut().print( "Hello World!" );
        } catch(IOException ioException) {
            throw new JspException("Error: " + ioException.getMessage());
        }
        return SKIP_BODY;
    }
}


in the WEB-INF folder I describe the helloworldTag.tld tag

<?xml version="1.0" encoding="ISO-8859-1"?>

<taglib xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
        version="2.1">

    <tlib-version>1.0</tlib-version>
    <short-name>mytag</short-name>
    <uri>/WEB-INF/helloworldTag</uri>

    <tag>
        <name>helloworld</name>
        <tag-class>ru.gadfil.jstl.HelloWorld</tag-class>
        <body-content>empty</body-content>

    </tag>

</taglib>


and in index.jsp I use it

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/helloworldTag.tld" prefix="mytag" %>
<%@ page session="false" pageEncoding="UTF-8" %>

<html>
<head>
    <title>my webapp</title>
</head>
<body>
<mytag:helloworld/>
</body>
</html>


I can't figure out how I connect everything to <%@ taglib uri="/WEB-INF/helloworldTag.tld" prefix="mytag" %> but the error remains

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Smirnov, 2014-08-18
@gadfi

Judging by the text of the error, the HelloWorld class itself was forgotten to be "put" on the server, or it ended up in a context inaccessible to the class loader that loads index.jsp. That is, either there is no class at all on the server, or it lies where the server did not guess from where to load it. In HelloWorld, classes usually lie in the HelloWorld.war/WEB-INF/classes folder
In general, JSP is an outdated technology, its modern version is JSF. Since the second version of the specification, creating your own components (analogous to JSP tags) has become a simple task...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question