Docstoc

Slide 1 - Learning Server

Document Sample
Slide 1 - Learning Server Powered By Docstoc
					Web Server On a Stick

 CCP111N support material
       Version 0.0
                What you get
• You should have two directories directly off
  the root of your memory stick:
• Java
  • This directory contains the java Software
    Development Kit (SDK) and includes a Java
    compiler.
• Mywebserver
  • This directory contains a cutdown version of
    Tomcat with JSP and Servlet support
              The Java Directory
• For web development
  the only useful thing is
  to know where the
  compiler is. Its in the
  bin directory...
• You can copy the Java
  directory and its sub
  directories to another
  drive and it does not
  need to be installed
                   Mywebserver
• Most of tomcat is found in the
  mywebserver/bin directory.
  Here you will find
  configuration files to setup
  tomcat and scripts to start
  and stop tomcat
• The libraries required to
  compile servlets and JSPs are
  in lib
• The log directory contains log
  files generated when tomcat
  runs
• The webapps directory
  contains websites
  Configuring and Running Tomcat
• Before you can run tomcat it must be configured.
• Inside the bin directory you will find a file called
  go_self_e.bat
   – This configuration file assumes that tomcat will be run
     from the e drive.
   – If your drive is not e: you will need to edit go_self_e.bat
     and change all the e: to what ever drive letter you are
     using (e: should be correct for the university machines)
   – You can copy the go_self_e.bat to a new name and put a
     different configuration in it. Before you start tomcat you
     will load the correct configuration for your situation.
              go_self_e.bat
set PATH="e:\Java\jdk1.6.0_06\bin";%PATH%
set JAVA_HOME=e:\Java\jdk1.6.0_06
set CLASSPATH=.;e:\mywebserver\lib\servlet-
  api.jar;e:\mywebserver\lib\jsp-
  api.jar;e:\mywebserver\lib\el-api.jar


            Check the drive letter are correct
                  for all these entries
                 Running Tomcat
• Once go_self_e.bat is
  configured you need to run
  tomcat
• You must run tomcat via a
  Msdos (command prompt).
  This program is usually
  found from the windows
  start menu -> programs ->
  accessories -> comment
  prompt
                     Running Tomcat
• Inside the prompt type (assuming you drive is the e drive)
    –   e:
    –   cd \mywebserver\bin
    –   go_self_e
    –   startup
                   Running Tomcat
• A new window should open showing tomcat starting up.
                      Running Tomcat
• Once tomcat has finished loading run your favourite web browser and in
  the url type in localhost
    – You should now see the default web site which includes a link to CCP111N
             Making a new web site
• Websites are stored inside \mywebserver\webapps
   – Create a new directory inside webapps (you can do this from the
     command prompt by typing
       • cd \mywebserver\webapps
       • mkdir ccp111n
       • This new directory (ccp111n) will hold both jsps and html pages
   – Inside this new directory create another directory called WEB-INF
       • cd ccp111n
       • mkdir WEB-INF
   – Inside WEB-INF create another directory called classes
       • cd WEB-INF
       • mkdir classes
       • Inside the classes directory is where the java source code for servlets should
         be placed and is where you will compile the source code using javac into a
         class file
Making a new web site



             Html and jsps go in
                   here



             Java Servlets go here
                       Urls
• If you website is in
  \mywebserver\webapps\ccp111n
• And you have a html file called hello.html
  – The url is http://localhost/ccp111n/hello.html
• And you have a jsp file called hello.jsp
  – The url is http://localhost/ccp111n/hello.jsp
• And you have a servlet file called hello.class in
  WEB-INF\classes
  – The url is http://localhost/ccp111n/servlet/hello

				
DOCUMENT INFO