File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes package javax.servlet.jsp does not exist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "package javax.servlet.jsp does not exist" Watch "package javax.servlet.jsp does not exist" New topic
Author

package javax.servlet.jsp does not exist

Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

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.


Life is easy because we write the source code.....
stanislav bashkirtsev
Ranch Hand

Joined: Aug 17, 2009
Posts: 75
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

Joined: Jul 15, 2008
Posts: 629

I have added them in my classpath, but still it gives error as package not found.
Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
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.


The future belongs to those who believe in the beauty of their dreams.Dream BIG!
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

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

Joined: Jul 23, 2009
Posts: 25
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: package javax.servlet.jsp does not exist