Signup · Login
Stardeveloper.com  
Home · Tutorials · Forums · ASP.NET Newsletter Application · Web Hosting Plans · Faisal Khan's Blog · Contact
Forums : J2EE : JSP : 10 errors when i compile TestServlet.java Signup · Login
Author Thread
10 errors when i compile TestServlet.java
Posted in tutorial: Introduction to Java Servlets, Developing your first Java Servlet
·  shibby1011ph
User
Joined: 20 Aug 2003
Total Posts: 7

10 errors when i compile TestServlet.java

Posted: 20 Aug 2003
i am using jsp and mysql along with jdk1.3.1_08, tomcat, redhat linux, apache for my current project. i decided to use servlets to enhance my project and make it more efficient.

however, when i compile TestServlet.java, it generates 10 errors.
one of these errors say that 'package javax.servlet' doesn't exist.
i tried searching j2ee.jar but my search results turn up empty.
so i checked the documentation and this is what it says :
-----------------------------------------
Q: What do I need in my CLASSPATH?
A: All you need is a correct version of JDK (1.1.x or 1.2).
Since the JSP engine also uses 'javac' it needs to be in the CLASSPATH.
If you are using JDK 1.1.x it will automatically be included. If
you are using JDK 1.2 you will need to set JAVA_HOME to the directory
where JDK is installed or alternately you can put "tools.jar" in your
CLASSPATH.

All other classes, jar files that are needed, are put by the startserver
script and you don't need to worry about them.

Q: Where are the classes for JSPs and Servlets?

A: webserver.jar -- class files for Servlet Engine.
lib/jspengine.jar -- class files for JSP Engine.
lib/servlet.jar -- Public APIs for Servlet.
lib/jsp.jar -- Public APIs for JSP.
lib/xml.jar -- classes for parsing XML document
---------------------------------------
so i put xml.jar, servlet.jar and webserver.jar in my classpath along with tools.jar.

i tried searching for jspengine.jar and jsp.jar but my search results turn up empty. what should i do? btw, below is my classpath (if it's any help at all):

export CLASSPATH=/usr/local/jdk1.3.1_08/jre/lib/rt.jar:/usr/java/lib/tools.jar:/usr/src/jakarta/dist/tomcat/lib/servlet.jar:/usr/src/jakarta/dist/tomcat/lib/webserver.jar:/usr/src/jakarta/dist/tomcat/lib/xml.jar:

i know a bit about java like methods, events, classes but i don't know much about jars and servlets. i'm still new to them so pls don't get mad

thank u very much

------------------
Just a JSP Newbie =)

Just a JSP Newbie =)
·  shibby1011ph
User
Joined: 20 Aug 2003
Total Posts: 7
solved my own problem!!!! yehey!!!!
Posted: 20 Aug 2003
hey people, guess what my problem was? i didn't restart my pc hahaha
thanks nway!!!!

Just a JSP Newbie =)
·  Faisal Khan
AdminAdminAdminAdmin
Joined: 24 Sep 2002
Total Posts: 595
Re: 10 errors when i compile TestServlet.java
Posted: 28 Oct 2007
You will get errors when you try to compile TestServlet.java without providing servlet-api.jar in the CLASSPATH. The correct way to compile TestServlet.java (as described fully in this tutorial) is with this command on the Command prompt:

C:\apache-tomcat-6.0.14\webapps\star\WEB-INF\classes\com\stardeveloper\servlets>
javac -cp %CATALINA_HOME%\lib\servlet-api.jar TestServlet.java

Please read this updated tutorial for more details.

Faisal Khan.
Stardeveloper.com
Read Blog | Follow on Facebook, Twitter
Want to leave a comment? Login or Register for free!

Users Who Have Visited This Thread In Last 24 Hours
2 Visitors

Login to post a comment or start a new thread
UserName Or Email Address:       Password:       Auto-Login:    
· Create New User Account
· Send Forgotten Password by Email
 
© 1999 - 2010 Stardeveloper.com, All Rights Reserved.