The Seventh Lab
JavaServer Pages
(I) Download Tomcat
Tomcat 8.0 or 7.0 or 6.0
Download the "Binary Distributions"
Choose zip file or tar.gz file for Linux and Mac machines
Choose 32-bit or 64-bit Windows zip file for Windows machines
In Linux and Mac machines, using echo $JAVA_HOME to check JAVA_HOME variable
In Windows machines, using echo %JAVA_HOME% to check JAVA_HOME variable
For the Linux machines in CS Undergrad Lab:
a) Open the terminal
b) Run vim .bashrc
c) Click button a to enter insert mode
d) Add export JAVA_HOME=/usr in one line
e) Click button Esc to quit insert mode
f) Type :wq to save and quit vim
g) Close the terminal
h) Reopen the terminal and check JAVA_HOME
For Mac machines Tutorial
For Windows machines Tutorial
(II) Start Tomcat Server
You should be able to find the bin folder under the Tomcat
In the bin folder, you should be able to see files catalina.bat and catalina.sh
Go to the bin folder
On Windows: .\catalina.bat start
On Linux and Mac: ./catalina.sh start
If there is an error message about permission denied, change the file permissions
On Windows: use file explorer
On Linux and Mac: use chmod command: chmod 744 *
You should be able to see Tomcat welcome webpage.
On Windows: .\catalina.bat stop
On Linux and Mac: ./catalina.sh stop
(III) Program with JSP
You should be able to see a folder webapps
For example, create lab7 folder under webapps directory
A sample jsp file is Here
Save it to index.jsp file. Remove ".txt"
Go to lab7 directory
Create a directory WEB-INF directory under lab7
Then create a directory classes directory under WEB-INF
Finally create a directory lab7 directory under classes
A sample java file is Here
Put the java file WelcomeInfo.java into the folder webapps/lab7/WEB-INF/classes/lab7/
(IV) Exercise
(V) External Reading