Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with Custom Tags

 
Shyam Kasthala
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Shyam Kasthala
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Satou, I got it now.Thank you very much.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic