This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes How do I compile mt Tag Handler...? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How do I compile mt Tag Handler...?" Watch "How do I compile mt Tag Handler...?" New topic
Author

How do I compile mt Tag Handler...?

Dan Mortimer
Greenhorn

Joined: Jun 01, 2004
Posts: 18
I am trying to write a very simple tag. The tag handler is below:

package basic;

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

class Hello extends TagSupport {
public int doStartTag() throws JspException {
try {
pageContext.getOut().print("Hello World");
}
catch (Exception ex) {
throw new JspException("IO problems");
}

return SKIP_BODY;
}
}

At the command line, I type the relevant command to compile my code:

javac Hello.java

The errors I get are as follows:

Hello.java:3: package javax.servlet.jsp does not exist
import javax.servlet.jsp.*;
^
Hello.java:4: package javax.servlet.jsp.tagext does not exist
import javax.servlet.jsp.tagext.*;
^
Hello.java:6: cannot resolve symbol
symbol : class TagSupport
location: class basic.Hello
class Hello extends TagSupport {
^
Hello.java:7: cannot resolve symbol
symbol : class JspException
location: class basic.Hello
public int doStartTag() throws JspException {
^
Hello.java:9: cannot resolve symbol
symbol : variable pageContext
location: class basic.Hello
pageContext.getOut().print("Hello World");
^
Hello.java:12: cannot resolve symbol
symbol : class JspException
location: class basic.Hello
throw new JspException("IO problems");
^
Hello.java:15: cannot resolve symbol
symbol : variable SKIP_BODY
location: class basic.Hello
return SKIP_BODY;
^

Do I need to download a library before I can compile this code, or am I missing something else...?

Thanks!

Dan
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You will need the J2EE classes in your class path in order to compile a custom tag handler. You can get these by downloading the J2EE development kit from sun, and the jar file you need is named j2EE.jar. Also, your application server has these classes. For Tomcat, they're in common/lib, and there are several jar files you have to include in your classpath.


Merrill
Consultant, Sima Solutions
Dan Mortimer
Greenhorn

Joined: Jun 01, 2004
Posts: 18
Hi Merrill,

Thanks very much for your response. I took your advice and added the 4 .jar files in my <TOMCAT_HOME>/common/lib directory to my classpath and now my custom tag handler compiles.

Thanks again for your help!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How do I compile mt Tag Handler...?
 
Similar Threads
Beginning JSTL Hello World Example Error
Eclips error
classic tag extends TagSupport
Problem with Custom Tags
JSP servlet compilation problem