0

I had been thru this link before i ask this question.

Generally when we browse http://localhost:80/ we see that ../tomcat/conf/web.xml (file1) is getting picked by servlet container but not ../tomcat/webapps/ROOT/WEB-INF/web.xml (file2), and there is nothing in file2.

Now, I have access to enterprise application which is available as default tomcat servlet(DTS), When i say DTS, it mean, when i type http://localhost:80/ I get the application page as http://localhost/ent-app/

My question:

In the link , it says to place the required app in ROOT folder to make specific servlet as DTS. But in my case, ROOT folder's WEB-INF/web.xml has nothing related to ent-app, Please help me understand, How my ent-app is being picked by servlet container as DTS?

What are the things that i need to check in tomcat folder of my machine for this to understand?

Community
  • 1
  • 1
overexchange
  • 15,768
  • 30
  • 152
  • 347
  • ROOT folder has nothing related to my specific app. ROOT/WEB-INF/web.xml has this... Welcome to Tomcat Welcome to Tomcat – overexchange Jun 01 '14 at 13:30

1 Answers1

1

If you want to redirect / to /ent-app, then you need to configure that. There is no magic provided by the ROOT web application: you need to configure it yourself to perform the redirect.

You can either write your own servlet/filter that maps to /* and just redirects everything to /ent-app, or you can use something like url-rewrite and simply configure it to your liking.

Christopher Schultz
  • 20,221
  • 9
  • 60
  • 77
  • if there is no magic provided by ROOT, THEN why the above link talks about replacing my servlet in ROOT? – overexchange Jun 01 '14 at 16:27
  • so that means, i need to check the web.xml in tomcat/webapps/ent-app/WEB-INF/web.xml to check how servlet mapping is done – overexchange Jun 01 '14 at 16:32
  • Your `ent-app` application will only be sent requests whose URLs start with `/ent-app/`. That means if you request `/foo` then the request will go to some other application. Assuming that `/foo` doesn't map to any *other* web application, it will be sent to the `ROOT` application. Just write a simple redirector from the ROOT web application to the `/ent-app` application. – Christopher Schultz Jun 02 '14 at 21:30
  • but why defaultservlet is pointed from tomcat/conf/web.xml ? This the web.xml that is directing what to do. So my question is, ideally this web.xml has to be in ROOT/WEB-INF folder. – overexchange Jun 03 '14 at 16:13
  • `CATALINA_BASE/conf/web.xml` is the default `web.xml` for all web applications. You should pretty much never edit it. What you want is a servlet (or filter) in your `ROOT` webapp that performs a redirect. That's possible to do *without* a `WEB-INF/web.xml`, but more straightforward if you do. `CATALINA_BASE/conf/web.xml` should never be under consideration for editing. – Christopher Schultz Jun 04 '14 at 20:57