Home arrow Java & J2EE arrow Page 6 - Slapping Together A JSP Development Environment

Putting It In Context - Java

Deploying a JSP development environment on your workstation cantest even the strongest of wills, since it requires the peacefulco-existence and cooperation of a number of complex software packages. Thistutorial guides you through the process of getting Apache, JServ and Tomcatconfigured, alerts you to some of the problems you're likely to encounter,and briefly discusses Tomcat contexts and JSP-mySQL connections. Coversboth Windows and Linux.

TABLE OF CONTENTS:
  1. Slapping Together A JSP Development Environment
  2. Essential Software
  3. One Tomcat, Standing Alone
  4. Connecting The Dots
  5. Same Story, Different OS
  6. Putting It In Context
  7. Making The Grade
By: icarus, (c) Melonfire
Rating: starstarstarstarstar / 4
March 05, 2001

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
The default Tomcat installation comes with a folder named "webapps", which contains sample files. You can place your JSP documents here, or you can define new locations from which to serve JSP files. In Tomcat-lingo, these locations are known as "contexts", and they're defined in the "server.xml" file in the Tomcat CONF directory.

Let's suppose that you wanted to serve files from the location http://localhost/jsp/, The first thing to do is to define a context in the Tomcat "server.xml" configuration file.

<Context path="/jsp" docBase="webapps/jsp/" debug="0" reloadable="true"> </Context>

This maps the location /jsp to the "webapps/jsp" folder.

Next, create a directory named "jsp" in the "webapps" folder, place the "hello.jsp" script there, and restart Tomcat and Apache. You should see the new context when Tomcat starts up.

Context log: path="/examples" Adding context path="/examples" docBase="webapps/examples" Context log: path="/test" Adding context path="/test" docBase="webapps/test" Context log: path="/jsp" Adding context path="/jsp" docBase="webapps/jsp/"

Now, when you point your browser to the URL http://localhost/jsp/hello.jsp, you should see the file being rendered correctly.

You can add as many contexts as you like, using the format above - however, these will always be one level below the server's document root. If you'd like to run JSP files from the document root itself, you should place them in the "webapps/ROOT" folder. For example, if the file "hello.jsp" was located in "webapps/ROOT", I would be able to access it via the URL http://localhost/hello.jsp.

If you're really picky, you can define an alternate location for the root folder by creating a new context - as the following example demonstrates:

<Context path="/" docBase="webapps/my/new/server/root" debug="0" reloadable="true" > </Context>

For more information on contexts, and how to tweak them for maximum performance, take a look at the Tomcat User Guide at http://jakarta.apache.org/

 
 
>>> More Java & J2EE Articles          >>> More By icarus, (c) Melonfire
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

JAVA & J2EE ARTICLES

- More Java Bugs Lead to More Attacks
- Oracle's Java One Brings News, Surprises
- Oracle Patches Java Runtime Environment
- Apple Syncs Java Update with Oracle
- Spring 3.1 Java Development Framework Compat...
- Jelastic Java PaaS Availability and Pricing ...
- NetBeans 7.1 Released, Supports JavaFX 2
- SolarWinds Releases Newest Version of Java M...
- Free Monitoring Tool for Java Apps on Heroku
- Heroku Adds JCloud Platform Support, Java 7 ...
- Java SE 8 Speculation in Full Swing
- Java SE 7 Now Available
- New JVM Language and Java Reporting Tool
- Java 7 Release Update and New Eclipse Toolkit
- The Best Java Netbeans IDE Plugins

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: