【linux_jdk_tomcat__servlet_jsp】:java后端编程入门——网站编程
【linux_jdk_tomcat__servlet_jsp】:java后端编程入门——网站编程
一、基本说明
1、 网站后端的编程原理: 网站后端的编程语言,绑定【路由】。【浏览器】访问【路由】,来实现【网站前端】和【网站后端】的数据交换。
---- 网站后端编程核心: java编程语言,绑定【路由】。
---- 网站前端和后端的数据交互: 【浏览器】访问【路由】;来实现网站前端和后端的数据交互。
---- 网站前端的核心功能: 展示数据,数据交互。
2、 环境说明: UBUNTU26.04 + JDK25.0.3 + TOMCAT11.0.22
3、 servlet环境编程
---- servlet环境的编程: 包含网站后端编程所需要的所有基础和核心内容。
---- servlet环境的编程: 是网站后端编程的极简模板。
4、 JSP环境的编程
---- JSP环境编程: JSP,首次封装“servlet”。JSP环境,包含java后续框架的核心内容。
二、工具下载(jdk + tomcat)
1、 JDK官网下载地址(下载二进制压缩包:解压即完成安装)
---- JDK_DOWNLOAD: https://www.oracle.com/java/technologies/downloads/
---- JDK_DOCS: https://docs.oracle.com/en/java/javase/26/
---- JDK_API_DOCS: https://docs.oracle.com/en/java/javase/26/docs/api/index.html
2、 TOMCAT官网下载地址(下载二进制压缩包:解压即完成安装)
---- https://tomcat.apache.org/
三、搭建开发环境
1、 JDK的安装(解压即安装完毕)
---- 解压位置/安装位置: /usr/local/userinstall/java/jdk
[wit@ubuntu:home]$ pwd
/usr/local/userinstall/java/jdk/home
[wit@ubuntu:home]$
[wit@ubuntu:home]$
[wit@ubuntu:home]$ ll
total 44
drwxr-xr-x 9 root root 4096 May 28 00:47 ./
drwxr-xr-x 3 root root 4096 May 28 00:48 ../
lrwxrwxrwx 1 10670 10670 23 Mar 11 08:39 LICENSE@ -> legal/java.base/LICENSE
-rw-r--r-- 1 10670 10670 290 Mar 11 08:39 README
drwxr-xr-x 2 root root 4096 May 28 00:47 bin/
drwxr-xr-x 5 root root 4096 May 28 00:47 conf/
drwxr-xr-x 3 root root 4096 May 28 00:47 include/
drwxr-xr-x 2 root root 4096 May 28 00:47 jmods/
drwxr-xr-x 71 root root 4096 May 28 00:47 legal/
drwxr-xr-x 5 root root 4096 May 28 00:47 lib/
drwxr-xr-x 3 root root 4096 May 28 00:47 man/
-rw-r--r-- 1 10670 10670 1242 Mar 11 08:39 release
[wit@ubuntu:home]$
---- 解压后的文件夹【xx】,改名为【home】
---- 设置环境变量(~/.bashrc):
#[CONFIG_JDK]
#JAVA_HOME=/usr/local/userinstall/java/jdk/home
#CLASSPATH=.
#export PATH=${JAVA_HOME}/bin:${PATH}
2、 TOMCAT的安装(解压即安装完毕)
---- 解压位置/安装位置: /usr/local/userinstall/java/tomcat
[wit@ubuntu:home]$ pwd
/usr/local/userinstall/java/tomcat/home
[wit@ubuntu:home]$
[wit@ubuntu:home]$
[wit@ubuntu:home]$ ll
total 168
drwxrwxrwx 9 root root 4096 May 28 00:48 ./
drwxr-xr-x 3 root root 4096 May 28 00:48 ../
-rwxrwxrwx 1 root root 26826 May 2 02:29 BUILDING.txt*
-rwxrwxrwx 1 root root 8626 May 2 02:29 CONTRIBUTING.md*
-rwxrwxrwx 1 root root 60517 May 2 02:29 LICENSE*
-rwxrwxrwx 1 root root 2333 May 2 02:29 NOTICE*
-rwxrwxrwx 1 root root 3224 May 2 02:29 README.md*
-rwxrwxrwx 1 root root 6470 May 2 02:29 RELEASE-NOTES*
-rwxrwxrwx 1 root root 16114 May 2 02:29 RUNNING.txt*
drwxrwxrwx 2 root root 4096 May 28 01:02 bin/
drwxrwxrwx 3 root root 4096 May 28 00:59 conf/
drwxrwxrwx 2 root root 4096 May 28 00:48 lib/
drwxrwxrwx 2 root root 4096 May 28 00:59 logs/
drwxrwxrwx 2 root root 4096 May 28 00:48 temp/
drwxrwxrwx 7 root root 4096 May 2 02:29 webapps/
drwxrwxrwx 3 root root 4096 May 28 00:59 work/
[wit@ubuntu:home]$
---- 说明: 解压后,要更改解压后文件夹的权限: sudo chmod -R 777 apache-tomcat-11.0.22 。解压后文件夹的权限是750,无法进入bin等目录、无法读写tomcat/logs文件夹内的文件;因此将解压后文件夹的权限更改为777。
---- 解压后的文件夹【xx】,改名为【home】
---- 设置环境变量:
#[CONFIG_TOMCAT]
#CATALINA=/usr/local/userinstall/java/tomcat/home
#export PATH=${CATALINA}/bin:${PATH}
---- 配置服务开关命令
---- 基本准备_脚本改名【位置: /usr/local/java/tomcat/home/bin 】
[wit@ubuntu:bin]$ pwd
/usr/local/userinstall/java/tomcat/home/bin
[wit@ubuntu:bin]$
[wit@ubuntu:bin]$
[wit@ubuntu:bin]$ ll
total 940
drwxrwxrwx 2 root root 4096 May 28 01:02 ./
drwxrwxrwx 9 root root 4096 May 28 00:48 ../
-rwxrwxrwx 1 root root 32201 May 2 02:29 bootstrap.jar*
-rwxrwxrwx 1 root root 1664 May 2 02:29 catalina-tasks.xml*
-rwxrwxrwx 1 root root 13650 May 2 02:29 catalina.bat*
-rwxrwxrwx 1 root root 21289 May 2 02:29 catalina.sh*
-rwxrwxrwx 1 root root 2123 May 2 02:29 ciphers.bat*
-rwxrwxrwx 1 root root 1997 May 2 02:29 ciphers.sh*
-rwxrwxrwx 1 root root 218507 May 2 02:29 commons-daemon-native.tar.gz*
-rwxrwxrwx 1 root root 26901 May 2 02:29 commons-daemon.jar*
-rwxrwxrwx 1 root root 2040 May 2 02:29 configtest.bat*
-rwxrwxrwx 1 root root 1922 May 2 02:29 configtest.sh*
-rwxrwxrwx 1 root root 8319 May 2 02:29 daemon.sh*
-rwxrwxrwx 1 root root 2091 May 2 02:29 digest.bat*
-rwxrwxrwx 1 root root 1965 May 2 02:29 digest.sh*
-rwxrwxrwx 1 root root 3606 May 2 02:29 makebase.bat*
-rwxrwxrwx 1 root root 3382 May 2 02:29 makebase.sh*
-rwxrwxrwx 1 root root 2096 May 2 02:29 migrate.bat*
-rwxrwxrwx 1 root root 1970 May 2 02:29 migrate.sh*
-rwxrwxrwx 1 root root 3382 May 2 02:29 setclasspath.bat*
-rwxrwxrwx 1 root root 3941 May 2 02:29 setclasspath.sh*
-rwxrwxrwx 1 root root 2020 May 2 02:29 shutdown.bat*
-rwxrwxrwx 1 root root 1902 May 2 02:29 shutdown.sh*
-rwxrwxrwx 1 root root 2022 May 2 02:29 startup.bat*
-rwxrwxrwx 1 root root 1904 May 2 02:29 startup.sh*
-rwxrwxrwx 1 root root 51025 May 2 02:29 tomcat-juli.jar*
-rwxrwxrwx 1 root root 474739 May 2 02:29 tomcat-native.tar.gz*
lrwxrwxrwx 1 root root 11 May 28 01:02 tomcatoff@ -> shutdown.sh
lrwxrwxrwx 1 root root 10 May 28 01:01 tomcaton@ -> startup.sh
-rwxrwxrwx 1 root root 3623 May 2 02:29 tool-wrapper.bat*
-rwxrwxrwx 1 root root 4600 May 2 02:29 tool-wrapper.sh*
-rwxrwxrwx 1 root root 2026 May 2 02:29 version.bat*
-rwxrwxrwx 1 root root 1908 May 2 02:29 version.sh*
[wit@ubuntu:bin]$
---- 复制文件【startup.sh】,并且将副本改名为【tomcaton】:
---- 【startup.sh】-->【tomcaton】: [wit@ubuntu:bin]$ sudo ln -sf startup.sh tomcaton
---- 【startup.sh】-->【tomcaton】: [wit@ubuntu:bin]$ sudo cp startup.sh tomcaton
---- 复制文件【shutdown.sh】,并将副本改名为【tomcatoff】:
---- 【shutdown.sh】-->【tomcatoff】: [wit@ubuntu:bin]$ sudo ln -sf shutdown.sh tomcatoff
---- 【shutdown.sh】-->【tomcatoff】: [wit@ubuntu:bin]$ sudo cp shutdown.sh tomcatoff
---- 配置开启服务命令(~/.bashrc):
---- export PATH=${CATALINA}/bin:${PATH}
3、 SERVLET编程环境的额外配置:
#[CONFIG_SERVLET]
#CLASSPATH=.:${CATALINA}/lib/servlet-api.jar
4、 JSP编程环境的额外配置:
#[CONFIG_JSP]
#CLASSPATH=.:${CATALINA}/lib/jsp-api.jar
5、 环境变量终极配置(JDK+TOMCAT+SERVLET+JSP)
#[JAVA_CONFIG_FINAL: JDK + TOMCAT + SERVLET +JSP ]
JAVA_HOME=/usr/local/userinstall/java/jdk/home
CATALINA=/usr/local/userinstall/java/tomcat/home
CLASSPATH=.:${CATALINA}/lib/servlet-api.jar:${CATALINA}/lib/jsp-api.jar
#export PATH=${JAVA_HOME}/bin:${CATALINA}/bin:${PATH}
6、 完整的配置文件
#[CONFIG_POSITION: ~/.BASHRC]
#[CONFIG_JDK]
#JAVA_HOME=/usr/local/userinstall/java/jdk/home
#CLASSPATH=.
#export PATH=${JAVA_HOME}/bin:${PATH}
#[CONFIG_TOMCAT]
#CATALINA=/usr/local/userinstall/java/tomcat/home
#export PATH=${CATALINA}/bin:${PATH}
#[CONFIG_SERVLET]
#CLASSPATH=.:${CATALINA}/lib/servlet-api.jar
#[CONFIG_JSP]
#CLASSPATH=.:${CATALINA}/lib/jsp-api.jar
#[JAVA_CONFIG_FINAL: JDK + TOMCAT + SERVLET +JSP ]
JAVA_HOME=/usr/local/userinstall/java/jdk/home
CATALINA=/usr/local/userinstall/java/tomcat/home
CLASSPATH=.:${CATALINA}/lib/servlet-api.jar:${CATALINA}/lib/jsp-api.jar
#export PATH=${JAVA_HOME}/bin:${CATALINA}/bin:${PATH}
四、网站后端编程入门的教程
1、 java编程教程: https://www.runoob.com/java/java-tutorial.html
2、 servlet编程教程: https://www.runoob.com/servlet/servlet-tutorial.html
3、 JSP编程教程: https://www.runoob.com/jsp/jsp-tutorial.html
五、参考资料
1、 菜鸟教程 -- https://www.runoob.com/
2、 JDK下载地址 - https://www.oracle.com/java/technologies/downloads/
3、 JDK_API_DOCS - https://docs.oracle.com/en/java/javase/26/docs/api/index.html
4、 JDK_DOCS - https://docs.oracle.com/en/java/javase/26/
5、 TOMCAT下载地址 - https://tomcat.apache.org/
.
本文由 lnlidawei 原创、整理、转载,本文来自于【博客园】; 整理和转载的文章版权归属【原创作者】; 转载或引用时【请保留文章的来源信息】:https://www.cnblogs.com/lnlidawei/p/20175516

浙公网安备 33010602011771号