Hi I am preparing for the SCWCD and just in the first few pages of HFSJ. I deployed a servlet using Tomcat. But there is a doubt that bugging me a lot.
Whenever we deploy a webapps , we need to make a entry into the server.xml. Can it be more dynamic .Actually I am compiling the classes in the separate directory and putting it to the Tomcat /webapps folder with the help of the ANT build Script.
Suppose I created a Webapps and directly put the classes file in the Tomcat home and restart it, can able to find the webapps to be working, without always making an entry to the server.xml.
Is there anything in the ANT Build script where we can make a change to the file by searching a particular string .Such as making an entry in the Server.xml file.
You should NOT be deploying webapps by modifying server.xml. That's been discouraged since Tomcat 4 came out. Despite what the Tomcat plugin for Eclipse WST does. Tomcat 3 should be beyond dead by now.
When you deploy a webapp, you have to set up a context. The context defines the root URL for the webapp. You can deploy in several ways.
1. Copy a WAR file into TOMCAT_HOME/webapps. If you do this, the context name will be the same as the WAR file name (minus the ".war").
2. Copy an exploded (unzipped) WAR into a directory in TOMCAT_HOME/webapps. The context name will be the same name as the directory name. Copying straight into the root or TOMCAT_HOME/webapps doesn't deploy to "/", however, so you do need a directory.
3. (recommended) Create a Tomcat Context as an xml file. Store this file into TOMCAT_HOME/conf/Catalina/localhost/. This allows you to specify custom parameters such as a security realm, database connection pools and server-specific settings. Although you can also save this file as META-INF/context.xml within a WAR, this way makes it easier to customize the configuration without rebuilding the WAR. If you have both META-INF/context.xml and this context file, this one will override the one in the WAR.
4. (not recommended) Add context to server.xml. I already commented on this.
When you update a deployed WAR, exploded WAR or context xml file, Tomcat will detect the changes and redeploy the webapp after a short delay. That's another reason for not defining deployments in server.xml - it can't be dynamically updated.
Dynamic redeployment doesn't always work as hoped. Complex apps may need to be stopped and restarted in order to ensure that various bits and pieces get cleanly reset.
Being persecuted doesn't in any way prove your righteousness or your beliefs. Many people get persecuted because they are repugnant or annoying. Or just because they can be.
Paper beats rock. Scissors beats tiny ad.
professionally read, modify and write PDF files from Java