Take a look at the servlet specification.

Basically you have to set up a context for your webapp. The web.xml file
describes your web-app. This means that you define your servlets and the
servlet-mapping (which urls will be mapped to which servlet) in web.xml

you could use something like this for your web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd";>

<web-app>
    <display-name>myapp</display-name>
    <servlet>
        <servlet-name>HelloIZ</servlet-name>
        <servlet-class>HelloIZ</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>HelloIZ</servlet-name>
        <url-pattern>/HelloIZExample</url-pattern>
    </servlet-mapping>
</web-app>


This means that the URL: /HelloIZExample will be mapped to the HelloIZ servlet 
as defined in the <servlet> section.


hf!

On Thu, 2006-02-16 at 15:37 +0100, Marc Wentink wrote:
> My excuses for such a simple question, but the archives are not =
> searchable and the documentation not very clear. Or may-be I am just a =
> terrible newbee.
> 
> Say I have a class file that contains a servlet, should not I do =
> something so that tomcat becomes the container of this servlet, and a =
> client browser could call the servlet? I expected to find some "install =
> class file that contains the servlet so Tomcat becomes it container" =
> option somewhere in the management part of Tomcat, but I am lost.
> 
> These are my files:
> 
> HelloIZ.java:
> 
> import java.io.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
> 
> public class HelloIZ extends HttpServlet {
> 
>     public void doGet(HttpServletRequest request, HttpServletResponse =
> response)
>     throws IOException, ServletException
>     {
>         response.setContentType("text/html");
>         PrintWriter out =3D response.getWriter();
>         out.println("<html>");
>         out.println("<head>");
>         out.println("<title>Hallo IntraZis!</title>");
>         out.println("</head>");
>         out.println("<body>");
>         out.println("<h1>Hallo IntraZis!</h1>");
>         out.println("</body>");
>         out.println("</html>");
>     }
> }
> 
> I have got the class file after setting my classpath to servlet.jar and =
> using javac.
> 
> And I thought I had to make some html to call the servlet:
> 
> StartServlet.html
> 
> <html>
> <head>
> <title>Hello Hospital!</title>
> </head>
> <body>
> <a href=3D"./HelloIZExample">go</a>
> </body>=09
> </html>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to