• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Compile TagHandler class using command prompt

 
Varatharuban B
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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



 
Vijitha Kumara
Bartender
Pie
Posts: 3930
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • 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.
 
Bert Bates
author
Sheriff
Posts: 8905
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just in case this conversation isn't finished yet, let's slide it over to the SCWCD forum...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic