This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
hi, 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.
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.
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. Bill
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.