• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Error compiling SimpleTagSupport class

 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Ritu varada
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found the answer in another thread!
https://coderanch.com/t/168885/java-Web-Component-SCWCD/certification/Simple-Tag
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic