File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I compile mt Tag Handler...?

 
Dan Mortimer
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dan Mortimer
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic