• 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 ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Can I deploy a Servlet differently?

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Or

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.

Thanks in Advance
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To invoke a servlet, there must be a mapping for it.

In production systems, this is often simplified by use of the Front Controller pattern.

If you search around long enough, you might find mention of "the Invoker". Don't go there. It's a discredited technology.
 
Saloon Keeper
Posts: 28328
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
when your children are suffering from your punishment, tell your them it will help them write good poetry when they are older. Like this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic