Depends on what you're trying to do.

Usually, a servlet engine allows for a mapping of URL names to the actual
Java class name. For example, in the JSWDK 1.0.1, in the
"servlet.properties" file in the WEB-INF directory of your web application,
you can define lines like so:

MyServlet=com.techgeeks.servlets.MyServletClass

(Note that its the fully-qualified package name, which means you leave off
the ".class" specification.) This will allow URLs of

http://www.exampleserver.com/servlet/MyServlet

to map into the com.techgeeks.servlets.MyServletClass class instance.

With other servlet engines, this may vary. The 2.2 Spec does define a
standard way of specifying this (the Deployment Descriptor, described in
pages 63-73 of the Specification, but since the Servlet 2.2 Spec is still in
"Public Release" mode (that is, it's not standardized yet), various engines
may not have implemented it entirely yet.

Under the 2.2 rules, the Deployment Descriptor defines this mapping like so
(this is the example from the Spec, abbreviated greatly):


<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
1.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>
    <display-name>A Simple Application</display-name>
    <context-param>
        <param-name>Webmaster</param-name>
        <param-value>[EMAIL PROTECTED]</param-value>
    </context-param>
    <servlet>
        <servlet-name>catalog</servlet-name>
        <servlet-class>com.mycorp.CatalogServlet</servlet-class>
        <init-param>
            <param-name>catalog</param-name>
            <param-value>Spring</param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>catalog</servlet-name>
        <url-pattern>/catalog/*</url-pattern>
    </servlet-mapping>
    ...
</web-app>

The key elements are the <servlet-class> tag, and the <servlet-mapping> tag.

HTH.

Ted Neward
Java Instructor, DevelopMentor ( http://www.develop.com )
http://www.javageeks.com/~tneward


-----Original Message-----
From: Ron Reynolds <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Tuesday, November 30, 1999 9:49 AM
Subject: packages and servlets?


>hi.  new to the list so this is sort of a test, but i also have a real
>question (hopefully not one that'll get me the "go check the archives!"
>response).
>i've tried putting my servlets into packages which has caused problems with
>referencing them from forms and such.  is there a way to do this?  (btw -
>environment is IIS3, JRun 2, just in case.)
>................ron.
>p.s., also new to Java so if it's a Java thing, not a Servlet thing, please
>forgive. :)
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to