Moose Moose
Moose Moose

Reputation: 267

How to configure tomcat so I can run my (java) web app at localhost

I've made a very small web app with eclipse, including

just echo'ing Hello world!. I've made my own build.xml file, and it's building succesfull. So now I've got my build folder, where HomeServer.class is located, and my web folder, where home.jsp is located.

I've downloaded Tomcat 7 (and got it working at localhost:8080), how can I configure my server.xml in a way that I can view my app at something like: localhost/app/home ? I'm running Windows

Upvotes: 0

Views: 3202

Answers (1)

JB Nizet
JB Nizet

Reputation: 692151

You don't need to configure anything in Tomcat. You should just create a directory structure like the following, and drop this directory in the webapps folder of Tomcat:

myWebApp
    WEB-INF
        classes
            com
                mypackage 
                    HelloServlet.class
        web.xml (optional if the servlet uses annotations)
    home.jsp

This is the structure of a standard Java EE webapp. It's described in every tutorial about Java EE webapps, and in Tomcat's documentation.

Note that it's a good idea to rely on Ant, Gradle or Maven to build your app, but that Eclipse (in its enterprise edition) supports Java EE webapps, and can create this structure for you and deploy the app directly from the IDE.

Upvotes: 5

Related Questions