• 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
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Compile TagHandler class using command prompt

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I face one problem in Head First SCWCD's Custom Tag Development (chapter 10) chapter.
When I try to compile a SimpleTagHandler file using following command I got some error.

E:\maruthi_wcd\ch10_tg_hnd>javac -classpath "c:\Program Files\apache-tomcat-6.0.16\lib\servlet-api.jar" -d classes src\com\foo\SimpleTagTest.java

Error
------
src\com\foo\SimpleTagTest.java:4: package javax.servlet.jsp does not exist
import javax.servlet.jsp.JspException;
^
src\com\foo\SimpleTagTest.java:5: package javax.servlet.jsp.tagext does not exist
import javax.servlet.jsp.tagext.SimpleTagSupport;
^
src\com\foo\SimpleTagTest.java:8: cannot find symbol
symbol: class SimpleTagSupport
public class SimpleTagTest extends SimpleTagSupport {
^
src\com\foo\SimpleTagTest.java:12: cannot find symbol
symbol : class JspException
location: class com.foo.SimpleTagTest
public void doTag() throws JspException, IOException {
^
src\com\foo\SimpleTagTest.java:16: cannot find symbol
symbol : method getJspContext()
location: class com.foo.SimpleTagTest
getJspContext().setAttribute("movie", movies[i]);
^
src\com\foo\SimpleTagTest.java:17: cannot find symbol
symbol : method getJspBody()
location: class com.foo.SimpleTagTest
getJspBody().invoke(null);
^
6 errors


---------------------------------------- This is the TagHandler class ------------------------
package com.foo;

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

public class SimpleTagTest extends SimpleTagSupport {

public SimpleTagTest(){}

public void doTag() throws JspException, IOException {
String[] movies = {"Sivaji", "Anniyan", "Kandasamy", "Johi"};

for(int i=0; i < movies.length; i++){
getJspContext().setAttribute("movie", movies[i]);
getJspBody().invoke(null);
}
}
}

Thanks in advance

Varatharuban



 
Bartender
Posts: 4109
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Those are from the JSP API not from the Servlet API, so have your jsp-api.jar available in the classpath.
 
author
Posts: 9031
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just in case this conversation isn't finished yet, let's slide it over to the SCWCD forum...
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic