• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Setting up contexts somewhere other than webapps

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Sir,

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.

How can i solve this problem

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I understand you correctly, you want to point the appbase to a new directory? If that is correct, you need to update conf/server.xml
and change appBase="E:/Project"

<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
 
Sheriff
Posts: 67590
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
Or, without touching server.xml at all, you can specify whatever docbase you want in the context files.
 
Kannan Alagar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Glenn Rogers ,

i was changed in my appBase path in server.xml file

<Host name="localhost" appBase="E:/Project"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">


Now the Tomcat web server is not running.

How to setting up contexts.

Thanks
 
Saloon Keeper
Posts: 24283
167
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
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.
 
Kannan Alagar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.



 
Kannan Alagar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Friends

Anybody how to run servlet file in Tomcat 7.0 other than webapps directory.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic