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.
We have ran into a problem when we tried to deploy our webapp on production server.
In our web.xml,we configured all the servlets with url-pattern of the format and we referred the servlet with this url-pattern throughout the application at numerous locations.The application worked fine on dev. server but when deployed on prod. server,due to its virtual mapping it expects /servlet before the servlet name as in
I recommend that you get your dev environment to match your production environment. If you know it's going to require the '/servlet' prefix, when you publish it the develop it with the same requirement.
Why the difference? Are you using different containers for dev and production? Are you using a combination of webserver + connector + container in your production environment?
Originally posted by Chris Corbyn: You just need to set the context-path for your application to be "" (empty). The /servlet context is a special tomcat feature allowing you to run servlets by name.
Without knowing more about the original poster's production environment, we can't really say that for sure.
The '/servlet' prefix might be a mapping set up in the connector between the webserver and application server. In fact, we don't even know if the original poster is using Tomcat. This is why I asked for clarification before trying to recommend a specific solution.
Joined: Jan 14, 2007
Quite true, my bad.
Joined: Nov 21, 2006
Our production server (javaservlethosting.com) is on virtual hosting environment.We dont have access to modify server configuration (server.xml and other configuration files).Whatever we can do,we can do at application level.
This is an excerpt from the production server deployment documentation saying how to access servlets.
Most hosting companies that offer Java hosting do so with a combination of the Apache Web Server and a container such as Tomcat or Resin. When they do this, they have to configure a properties file and set up the URL patterns that will be mapped to the servlet container. It's common to use /servlet/* and *.jsp.
You should find out what they're doing and set up your development machines the same way. If you can't do this, you should, at least, try to set up a QA machine with the same settings so you can test your code in an identical environment before promoting to the production box.
If you can't get the two to match, you might need to keep two copies of your deployment descriptor (one with the /servlet/ mapping for production and one without for development. You could also set up a context-init-param to represent the prefix and use that to build your links in the JSPs.