aspose file tools*
The moose likes JSP and the fly likes Problem with Custom Tags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Problem with Custom Tags" Watch "Problem with Custom Tags" New topic
Author

Problem with Custom Tags

Shyam Kasthala
Ranch Hand

Joined: Mar 30, 2006
Posts: 48
Hi,
When i am compiing the folowing code i am getting this error,Can any one help me what to do?

package oreilly.examples;

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

public class Hello extends TagSupport {
private String name=null;

public void setName(String value){
name = value;
}

public String getName(){
return(name);
}

public int doStartTag() {
try {
JspWriter out = pageContext.getOut();
out.println("<table border=1>");
if (name != null)
out.println("<tr><td> Hello " + name + " </td></tr>");
else
out.println("<tr><td> Hello World </td></tr>");
} catch (Exception ex) {
throw new Error("All is not well in the world.");
}

return SKIP_BODY;
}

public int doEndTag(){
try {
JspWriter out = pageContext.getOut();
out.println("</table>");
} catch (Exception ex){
throw new Error("All is not well in the world.");
}
}
}

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 find symbol
symbol: class TagSupport
public class Hello extends TagSupport {
^
Hello.java:19: cannot find symbol
symbol : class JspWriter
location: class oreilly.examples.Hello
JspWriter out = pageContext.getOut();
^
Hello.java:19: cannot find symbol
symbol : variable pageContext
location: class oreilly.examples.Hello
JspWriter out = pageContext.getOut();
^
Hello.java:29: cannot find symbol
symbol : variable SKIP_BODY
location: class oreilly.examples.Hello
return SKIP_BODY;
^
Hello.java:34: cannot find symbol
symbol : class JspWriter
location: class oreilly.examples.Hello
JspWriter out = pageContext.getOut();
^
Hello.java:34: cannot find symbol
symbol : variable pageContext
location: class oreilly.examples.Hello
JspWriter out = pageContext.getOut();
^
8 errors


Thank you.


Thanks & Regards<br /> Shyam Kasthala<br />ILFS Infotech Limited
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

You need to put jsp-api.jar and servlet-api.jar in your CLASSPATH.
They are probably in a lib directory somewhere within your web container's distibution.


[My Blog]
All roads lead to JavaRanch
Shyam Kasthala
Ranch Hand

Joined: Mar 30, 2006
Posts: 48
Hi,
servlet-api.jar and jsp-api.jar are located in
C:\Program Files\Tomcat 5.5\common\lib directory in my system.How can i set the classpath now.In my classpath i have C:\Program Files\Tomcat 5.5\common\lib\servlet-api.jar;Now how can i set jsp-api.jar??? Please tell me.Thanks for your response.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

If your compiling from the command prompt :
SET CLASSPATH="C:\Program Files\Tomcat 5.5\common\lib\jsp-api.jar";%CLASSPATH%
Shyam Kasthala
Ranch Hand

Joined: Mar 30, 2006
Posts: 48
Thank you very much Satou, I got it now.Thank you very much.
 
 
subject: Problem with Custom Tags