Hello. I am attempting to run a simple servlet to become familiar with how servlets work. I am attempting to compile something like the following code in the standard manner (using javac):
The compiler comes back saying that "package javax.servlet does not exist" and "package javax.servlet.http does not exist". Is this a CLASSPATH problem? Do I have to go out on the Web and get the API's that javax contains, or would I have already downloaded them with JDK1.3? Any help you could offer would be greatly appreciated. Thank you one and all, Art
hai u have to download servlet development kit from the sun's site then check if src/javax/servlet subdirectory exists it should have java & its equivalent class files in it if not there will be a jar file in lib directory(jsdk.jar) extract the jar file and then u will get javax/servlet subdirectory with .class files then copy it to your examples directory & try to run the file it will run..
Please note that although you will often find suggestions to download the servlet development kit from Sun, this is not usually a good idea. Sun stopped development in the servlet development kit a long time ago, and handed over development to the Apache group. If you wish to get started with servlets, the best thing to do is to download one of the many free servlet-capable web servers, which will give you not just the ability to compile servlets, but a way to test and run them too. The official reference implementation of the servlet container is Tomcat, available from http://jakarta.apache.com/ , but if you look through th epast messages in this forum you will see that many people have problems installing it and getting it to run. I personally use Resin, from http://www,caucho.com/ which runs very fast, and is usually a lot easier to get working. Both of these come with examples and documentation, so it's usually worth downloading one of them, even just for reference.
I agreee with Frank. Ashok, If you want to put something in the jar file into your classpath, you don't need to extract them. You can put the jar file as it is into your classpath. If you want to put c:\myjava\lib\xxx.jar in your classpath, you have to give full path of the jar file like set classpath=%classpath%;c:\myjava\lib\xxx.jar
I too have spent hours and hours trying to work out why, despite setting my CLASSPATH correctly to point to the servlet.jar archive in the Tomcat installation, the javac compiler refuses to find it and thus gives such messages as "package javax.servlet does not exist". By searching on Sun's java sites, the Tomcat site, and many mailing lists, I saw that tons of people were having the same problem, and the only replies offered were of the form "are you *sure* you've set the CLASSPATH properly?!" Naturally, I was sure I had, but as it turns out, I hadn't: There was a problem with case-sensitivity, at least on my system (Windows ME). The servlet.jar file was located as follows: C:\Program Files\Tomcat-3.2.3\lib\servlet.jar and I was setting CLASSPATH as follows: CLASSPATH=.;C:\PROGRA~1\TOMCAT~1.3\LIB\SERVLET.JAR (the ".;" bit placed at the start as recommended at http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/index.html) I was using DOS filenames because I *thought* that was the safest thing to do whenever programs like Tomcat that involve DOS are involved. But then I finally tried setting the path as: CLASSPATH=.;C:\PROGRA~1\TOMCAT~1.3\lib\servlet.jar and that solved the problem.
I am trying to do the same thing with no luck. I have tried everything listed in this post and replys, and nothing is working for me. I have tomcat 4.0 installed in windows nt 4.0, which works fine when i go to http://localhost:8080. the servlets that are there operate properly, but i cannot compile them (or any others) without getting a package javax.servlet does not exist error every time. I have d:\j2sdkee1.3 set as J2EE_HOME, D:\JDK13~1.1_0 set as JAVA_HOME (although i have tried d:\jdk1.3.1_01 as well). my PATH includes %JAVA_HOME%\bin and %J2EE_HOME%\bin. I have tried my CLASSPATH with .; ... .;C:\PROGRA~1\APACHE~1.0\server\lib\servlet.jar; ... (as suggested above) Why is nothing I am trying working, and even more important, why is this not properly documented on how to set this up? If anyone can help me, I would be extremely grateful.
hello.... I've face the same problem and i have check servlet.jar and j2ee.jar Both of these is inside my lib. Below is my clsspath and path.... CLASSPATH --->%CLASSPATH%;C:\jakarta-tomcat-5.0.19\webapps\ROOT\WEB-INF\classes; C:\jakarta-tomcat-5.0.19\webapps\ROOT\WEB-INF\lib\servlet.jar; C:\jakarta-tomcat-5.0.19\webapps\ROOT\WEB-INF\lib\j2ee.jar PATH ---> C:\Program Files\j2sdk_nb\j2sdk1.4.2
Could anybody help me...I'm new in this area.. Then 1 more qustion, after setting the environment could we have to restart our pc. Lastly do we need to install J2EE Platform..