I downloaded the JSDK2.1 a few days ago, and extracted into D:\JSDK2.1. Now I want to write servlets in Java, and don't know what I should do so that the import statement in the code works.
.
Printable View
I downloaded the JSDK2.1 a few days ago, and extracted into D:\JSDK2.1. Now I want to write servlets in Java, and don't know what I should do so that the import statement in the code works.
.
cudabeanCode:import javax.servlet.*;
import javax.servlet.http.*; // might not be req'd
public class MyClass extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp) {
try {
} catch (Exception e) {}
}
// and/or public void doPost(...)
}
That much Java I know. I want to know how/where I should set up my directory structure with the extracted class files. At present it's in D:\JSDK2.1\JavaX\Servlet and D:\JSDK2.1\JavaX\Servlet\Http. I want to know how I can tell Java to include this in its classpath or whatever so my import statements work.
.
I once used an App Server called JRun that had you put your custom classes in a specific directory off of the JRun installation so that the app server could serve your custom classes. So I'd expect it to be in the documentation for the JSDK. I'm sure I saw it for the JSDK before I went with JRun.
Sorry if that doesn't help any.
Edit-
I found http://java.sun.com/docs/books/tutor...rt.html#config
which says that class files are put in
webpages/WEB-INF/servlets
Also, before that,
Quote:
It is possible for you to configure various properties of the JSDK server before you start it. These properties include the server's port, which defaults to 8080, the hostname of the server, which defaults to localhost, and the document root, which defaults to the webpagessubdirectorythe JSDK installation. To see or update these configuration values, edit the default.cfg file in the JSDK installation directory.
No help at all. I don't want help on how to configure and run servlets. This is a very basic problem. I have to somehow modify the ClassPath so that I can use the servlet and http classes.
.
When you compile, you can specify the classpath as the argument:
Code:javac -classpath PathToYourClassesHere YourFileToCompile.java
OK, some help there. Serge, how do I modify the ClassPath variable so it can also incorporate the JSDK classes?Quote:
Originally posted by Serge
When you compile, you can specify the classpath as the argument:
Code:javac -classpath PathToYourClassesHere YourFileToCompile.java
At present I have JDK1.2.2 installed in D:\JDK1.2.2 and the ClassPath points to the JAR files in this folder. How do I modify it so it also includes D:\JSDK2.1 classes?
.
For those who are as dumb as me, here is what was wrong. I did set the correct path in the ClassPath environment variable, but that was in DOS. I forgot to do the same in the JCreator settings. As a result, whenever I tried to compile the code from JCreator, it could not find the required package. When I compiled it through DOS, it went fine.
So, when using JCreator, it's not enough to modify your environment variables. It's also required that you reflect these changes in the JCreator settings as well.
.