You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@jakarta.apache.org by Eyal Rabinovich <EY...@amdocs.com> on 2000/10/15 16:32:04 UTC

servlet packed in package.

Hi All

Is it possible for the Tomcat to run servlet that is part of a package ?
Can the servlets be packed in .jar file ?

 Thanks Eyal

Re: servlet packed in package.

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Eyal Rabinovich wrote:

> Hi All
>
> Is it possible for the Tomcat to run servlet that is part of a package ?
>

Sure.  You can do this in two different ways --

* Through the invoker servlet:

    http://localhost:8080/myapp/servlet/com.mycompany.mypackage.MyServlet

* By setting up servlet mappings in web.xml:

    <servlet>
        <servlet-name>My Cool Servlet</servlet-name>
        <servlet-class>com.mycompany.mypackage.MyServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>My Cool Servlet</servlet-name>
        <url-pattern>/myservlet/*</url-pattern>
    </servlet-mapping>

  The above servet is accessible through URLs like:

    http://localhost:8080/myapp/myservlet

See below for where to put the classes for your servlet itself.

> Can the servlets be packed in .jar file ?
>

Yes.  You've again got two choices:

* Unpacked under WEB-INF/classes inside your webapp:

    WEB-INF/classes/com/mycompany/mypackage/MyServlet.class

* Packed in a JAR file of any name, under WEB-INF/lib.  The
  packaged directory structure must reflect the Java package
  structure in the usual way for JAR files.

>
>  Thanks Eyal
>

Craig McClanahan

====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat