I am using Java 6.0 and Tomcat 7.0. I am running jsp and servlet file using Tomcat 7.0. But all my files are stored like JSP File --> "C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\examples\jsp" folder.
Like Servlet file --> "C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\examples\WEB-INF\classes". But i want run jsp and servlet file in my user area (E:\Project). not apache examples folder.
First, unzip a fresh copy of your server.xml file from the Tomcat zip file you downloaded and installed from. Replace the server.xml you damaged with this original copy. Check to make sure Tomcat works again.
Tomcat is designed to host multiple web applications, not simply be a loose collection of servlets and JSPs, so you need to have defined an application to contain your servlets/JSPs, and it must be in WAR format. In the 100% pure J2EE spec, the WAR should be a single file in JAR format, but Tomcat also allows you to work with "exploded" WARs, which is the set of directories that you get when you unzip a WAR file. The directory that contains this exploded WAR is your docBase.
You can use a Context to define a webapp, and set its docBase to something like "E:/Projects/examples". To do that, you create a file named "XXXXXX.xml" containing a <Context> element and copy it to the TOMCAT_HOME/conf/Catalina/localhost directory. A Context looks something like this:
When you start up Tomcat, you should then be able to run your examples with URLs such as "http://localhost:8080/XXXXXX/test.jsp", where "XXXXXX" is the name of the XML file containing your Context definition. Please note that in this type of configuration the "path" attribute of the Context is not used to define the webapp's URL context. It uses the context filename (minus the .xml).
For best results, delete any directories and files under TOMCAT_HOME/webapps/examples (including the examples directory itself). They tend to take precedence over other webapp definitions, and may actually overwrite your XXXXXX.xml file in some cases.
When it comes to destroying a civilization, gas chambers cannot hold a candle to echo chambers.
posted 8 years ago
Hello Tim Holloway,
Thanks for your reply. I created xml file in TOMCAT_HOME/conf/Catalina/localhost directory. Now JSP file is running. How to run servlet file.
posted 8 years ago
Anybody how to run servlet file in Tomcat 7.0 other than webapps directory.