The JavaTM Tutorial

| Start of Tutorial > Start of Trail | Search Feedback Form

Trail: Servlets

## Lesson: Running Servlets

> This lesson shows you a few ways to invoke servlets:

### Typing a servlet URL into a browser window

> Servlets can be called directly by typing their URL into a browser's location window. This is how you access the main page of the Duke's Bookstore example. This section shows you the general form of a servlet URL.

### Calling a servlet from within an HTML page

> Servlet URLs can be used in HTML tags, where a URL for a CGI-bin script or file URL might be found. This section shows servlet URLs being used as the destination of an anchor, as the action in a form, and as the location to be used when a META tag directs that a page be refreshed. This section assumes knowledge of HTML. If you don't know HTML you can learn about it through various books or by looking at the HTML 3.2 Reference Specification.

This lesson assumes:

- Your machine, `localhost`, is running the JSDK server (JSDK 2.1) or servletrunner (JSDK 2.0) or a servlet-enabled web server such as the Java Web Server at port 8080
- The servlet example, Duke's Bookstore, is located in the top-level of that process's directory for servlets. For the JSDK 2.1 server, this means that the class files are in the WEB-INF subdirectory of the server's document root. For `servletrunner` (JSDK 2.0), this means that the class files are in the servlet directory specified by the `-d` option.

If these two things are true, then you should be able to run the servlet example by typing in the URLs given in the example.

| Start of Tutorial > Start of Trail | Search Feedback Form