wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Error compiling SimpleTagSupport class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Error compiling SimpleTagSupport class" Watch "Error compiling SimpleTagSupport class" New topic
Author

Error compiling SimpleTagSupport class

Ritu varada
Ranch Hand

Joined: Sep 08, 2004
Posts: 117
I have the standard.jar and jstl.jar in my classpath. But the following class gives me the below compilation errors.

This is the class
package foo;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.IOException;



public class AdvisorTagHandler extends SimpleTagSupport {

private String user;

public void doTag() throws JspException,IOException {
getJspContext().getOut().write("Hello" + user + "<br> ");
getJspContext().getOut().write("Your advice is " + getAdvice());

}

public void setUser(String user) {

this .user = user;
}

String getAdvice() {

String[] adviceStrings = {"The color is not right for you","You should call in sick:","You shoudl rethink your haircut"};

int random = (int) (Math.random() * (adviceStrings.length) );

return adviceStrings(random);
}
}

I am getting the following compilation errors :



Directory of C:\HeadFirstServlets\CustomTagTest\foo

01/24/2005 10:56 AM <DIR> .
01/24/2005 10:56 AM <DIR> ..
01/24/2005 10:58 AM 781 AdvisorTagHandler.java
01/24/2005 10:45 AM 1,053 CustomTagTest.class
01/24/2005 10:45 AM 819 CustomTagTest.java
3 File(s) 2,653 bytes
2 Dir(s) 25,745,915,904 bytes free

C:\HeadFirstServlets\CustomTagTest\foo>cd ..

C:\HeadFirstServlets\CustomTagTest>javac foo\AdvisorTagHandler.java
foo\AdvisorTagHandler.java:4: cannot resolve symbol
symbol : class SimpleTagSupport
location: package tagext
import javax.servlet.jsp.tagext.SimpleTagSupport;
^
foo\AdvisorTagHandler.java:9: cannot resolve symbol
symbol : class SimpleTagSupport
location: class foo.AdvisorTagHandler
public class AdvisorTagHandler extends SimpleTagSupport {
^
foo\AdvisorTagHandler.java:14: cannot resolve symbol
symbol : method getJspContext ()
location: class foo.AdvisorTagHandler
getJspContext().getOut().write("Hello" + user + "<br> ");
^
foo\AdvisorTagHandler.java:15: cannot resolve symbol
symbol : method getJspContext ()
location: class foo.AdvisorTagHandler
getJspContext().getOut().write("Your advice is " + getAdvice());
^
foo\AdvisorTagHandler.java:30: cannot resolve symbol
symbol : method adviceStrings (int)
location: class foo.AdvisorTagHandler
return adviceStrings(random);
^
5 errors


What am I missing ?


SCJP,SCWCD(1.4)
Ritu varada
Ranch Hand

Joined: Sep 08, 2004
Posts: 117
I found the answer in another thread!
http://www.coderanch.com/t/168885/java-Web-Component-SCWCD/certification/Simple-Tag
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error compiling SimpleTagSupport class
 
Similar Threads
JSTL + help needed
problem in custom taglib
custom "advice" tag example
org.apache.jasper.JasperException: Unable to compile class for JSP:
Custome Tag Problem