• Post Reply Bookmark Topic Watch Topic
  • New Topic

package javax.servlet.jsp does not exist

 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody..
I have tried to run following simple tag handler, from HFSJ named "AdviserTagHandler.java"

package foo;

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

public class AdviserTagHandler extends SimpleTagSupport
{
private String user;

public void doTag() throws JspException,IOException
{
getJspContext().getOut().write("Hello"+user+"
");
getJspContext().getOut().write("Your advice is:"+getAdivce());
}

public void setUser(String user)
{
this.user = user;
}

String getAdive()
{
String[] adviceString = {"That color's is not working for you","You should call in sick.","You might have to rethink that haircut."};
int random = (int)(Math.randon()*adviceString.length);
return adviceString(random);
}
}



but it gives me error like

1)src/foo/AdviserTagHandler.java:3: package javax.servlet.jsp does not exist
import javax.servlet.jsp.JspException;
^
2)src/foo/AdviserTagHandler.java:4: package javax.servlet.jsp.tagext does not exist
import javax.servlet.jsp.tagext.SimpleTagSupport;
^
3)src/foo/AdviserTagHandler.java:7: cannot find symbol
symbol: class SimpleTagSupport
public class AdviserTagHandler extends SimpleTagSupport
^
.......................

Please help me how to compile this program.
 
stanislav bashkirtsev
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What libs have you added? As far as I remember you should add servlets-api.jar, j2ee-api.jar to your project's classpath.
 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have added them in my classpath, but still it gives error as package not found.
 
Nabila Mohammad
Ranch Hand
Posts: 664
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why you don't you tell us your command , what you write at the command prompt.May be that will help us to point out your problem.
 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had not set the jsp.jar in my classpath but after setting it in classpath the problem was solved.

Thank you
 
William Asher
Greenhorn
Posts: 25
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know this is an ancient thread and I hope I don't cause heartache by posting to it - however I just wanted to add that I just ran into this same issue (with the same AdvisorTagHandler class), and resolved it by adding jsp-api.jar to the classpath. That Jar file is present in my Tomcat 5.5.36 implementation in the common\lib directory.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!