A little help required with Servlets and Tomcat 4.0


Web tier: servlets, JSP, Web frameworks: A little help required with Servlets and Tomcat 4.0

  1. A little help required with Servlets and Tomcat 4.0 (3 messages)

    I just installed the latest version of tomcat and successfully created a jsp page.

    I would really appreciate it if someone could point me in the right direction of servlet examples being deployed on tomcat. I set up my project structure as recommended in the tomcat documentation.

    I'm familiar with the setup of the web.xml file in relation to servlets. I just need to know the directory structure under the webapps directory where i should place my jar/class files.

    I'm only asking because I want to start of with good habits right from the start. I'm looking on the web for some examples, but any hunts/suggestions would be very much appreciated.



  2. Gr8 now that you have Catalina up and running you need to deploy your JSP's and Servlets

    According to J2EE specification directory structure should be like this:
           (your application)
                Images ->images go here
                JSP ->Jsps go here
                src ->Java source files go in here
                    Classes ->Your Class files/jar files go here


  3. Thanks very much for your prompt response.

    My application directory under the webapps directory is named artist. I have changed the context path in the server.xml file to
      <Context path="/artist" docBase="" debug="0"/>

    I get the following error displayed when i start tomcat. could you please help me resolve this problem?

    The error message is as follows:

    0 StandardHost[localhost]: ContainerBase.removeChild: stop:
    LifecycleException: Container StandardContext[/examples] has not been started
    at org.apache.catalina.core.ContainerBase.stop(Unknown Source)
    at org.apache.catalina.core.StandardContext.stop(Unknown Source)
    at org.apache.catalina.core.ContainerBase.removeChild(Unknown Source)
    at org.apache.catalina.core.StandardHostDeployer.remove(Unknown Source)
    at org.apache.catalina.core.StandardHost.remove(Unknown Source)
    at org.apache.catalina.startup.HostConfig.undeployApps(Unknown Source)
    at org.apache.catalina.startup.HostConfig.stop(Unknown Source)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(Unknown Source)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Unknown Source)
    at org.apache.catalina.core.ContainerBase.stop(Unknown Source)
    at org.apache.catalina.core.ContainerBase.stop(Unknown Source)
    at org.apache.catalina.core.StandardService.stop(Unknown Source)
    at org.apache.catalina.core.StandardServer.stop(Unknown Source)
    at org.apache.catalina.startup.Catalina.start(Unknown Source)
    at org.apache.catalina.startup.Catalina.execute(Unknown Source)
    at org.apache.catalina.startup.Catalina.process(Unknown Source)
    at java.lang.reflect.Method.invoke(Native Method)
    at org.apache.catalina.startup.Bootstrap.main(Unknown Source)

    Kindest Regards,

  4. Hello again.

    server.xml file has to be wel formed.
    Your document base cannot be empty.

    for EG:
    <Context path="/examples"

    The docBase :examples is the webapplication directory under the webapps directory of your tomcat.
    you may also set your directory to any other folder on any of your drive.
    <Context path="/examples"
             docBase="c:\program files\apache\myfolder\examples"

    During start up Tomcat references the server.xml file and makes alive all the existing context paths.

    Try this and hope it works.