Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Setting up Website without the context element in Server.xml

Ranch Hand
Posts: 62
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am currently developing website for a Client 'simliv'
We have developed some good 3/4 working pages and the client want to host this website on the internet.So the Client has decided to use its existing
IDC (Internet Data Center).

PROBLEM: But the Client's IDC allows the client to access only webapps folder under tomcat. ie any damn file for the website can be placed under
webapps in folder simliv.The Client cannot access any folder like logs,bin etc.

Now while inhouse development we have used a External Resource in Web.xml using <resource-ref> tag and the actual parameters for the resource is in Server.xml under <context> in
<Resource /> <ResourceParams > tags.

My Questions:

1>Is it possible to run a website in tomcat without adding <Context> element parameter (ie without configuring Context in Server.xml) in Server.xml

2>Can i shift the external resource(type javax.sql.DataSource) defined in Server.xml to Web.xml.

3>Can i prevent the information to be written under folder 'logs' in the file localhost or catalina.out for my website.

All this becoz IDC doesnot allow Client to access any folder other than Webapps and particularly 'simliv' under webapps.

please reply
Author and all-around good cowpoke
Posts: 13078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. When Tomcat starts, it will recognize folder under webapps as legitimate web applications if they have a WEB-INF directory with a valid web.xml file in it. If you can't restart, the alternative is to use the Manager application's html interface to add the application.
2. - I don't know
3. I think you can override the default logger defined in server.xml but I'm not sure how.
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you probably won't like some of my answers.

1) Yes, in Tomcat 5.x there is a concept of a context.xml file. You would put this file in the WAR file that you upload (I think in META-INF ??) and TC would use the <context> entries you supply, and you wouldn't need access to server.xml. But if you IDC doesn't have TC5.x, you're out of luck on this count as well (and besides, it sounds like they're running in 'exploded' mode, and wouldn't support *.war files anyways).

2) You can't really *shift* the elements, but you can change how you create them. Instead of relying on container-managed resources (like DataSources), you can set up those resources in your own application, and configure them based on context-param's you've placed in web.xml. There's lots of folks that like to do this, because of just the situation you describe ( they have no access to the container, and so they must manage everything themselves anyway ).

3) I don't know if you can 'prevent' this. If you use System.out, then where this ends up is a tomcat configuration (out of your control). If you use ServletContext.log() then this is *also* up to the container configuration. If you truly want completely separate logging, configurable and controlled by you, you need to use something like log4j.jar. This runs along the same lines as my answer for #2. Don't depend on the container for anything.
    Bookmark Topic Watch Topic
  • New Topic