何为JSP
动态网页需要使用到的服务端脚本语言(JSP)
BS架构
CS架构:Client Server。例如QQ 微信 CS游戏
缺点:软件升级,全部软件升级/维护麻烦,需要维护每一台客户端软件/每一台客户端都需要安装客户端软件
BS架构:Browser Server。网页版京东、百度
客户端可以通过浏览器直接访问客户端
TomCat服务器
tomcat解压后目录:
![87449695286991bfce4470fb8a132c51.png](https://img-blog.csdnimg.cn/img_convert/87449695286991bfce4470fb8a132c51.png)
- 配置jdk(必须配置JAVA_HOME)ClassPath Path
- 配置Catalina_home
- 双击bin/startup.bat启动tomcat
- 常见错误:可能与其他服务的端口号冲突,默认端口号8080(常见容易冲突),建议修改在配置文件conf里的server.xml修改
- 访问tomcat local:8080/
常见状态码
![75100478a9b0f03a00efa13639b12c10.png](https://img-blog.csdnimg.cn/img_convert/75100478a9b0f03a00efa13639b12c10.png)
一个自己写的项目需要什么
![fed441ad20667f01558da7acbfafee54.png](https://img-blog.csdnimg.cn/img_convert/fed441ad20667f01558da7acbfafee54.png)
写一个jsp文件
jsp:在html里嵌套的java代码(<% %>里面的内容)
![c07936cdc66940423f0563aed633eb62.png](https://img-blog.csdnimg.cn/img_convert/c07936cdc66940423f0563aed633eb62.png)
![65568925b226dfa099213cfaa461e9c3.png](https://img-blog.csdnimg.cn/img_convert/65568925b226dfa099213cfaa461e9c3.png)
![5fa654547463d9b80bbfc844b0c022c4.png](https://img-blog.csdnimg.cn/img_convert/5fa654547463d9b80bbfc844b0c022c4.png)
6. 配置虚拟路径(这块先不看了,以后再说)
![8cad7034fc9590ebdf0894a864e7eeb9.png](https://img-blog.csdnimg.cn/img_convert/8cad7034fc9590ebdf0894a864e7eeb9.png)
![262da6d1fb1fcf949fca15f59d74f14e.png](https://img-blog.csdnimg.cn/img_convert/262da6d1fb1fcf949fca15f59d74f14e.png)
![9209203cd5f651fe9aa241ef31bff8b4.png](https://img-blog.csdnimg.cn/img_convert/9209203cd5f651fe9aa241ef31bff8b4.png)
JSP执行流程
![d082e058301600a9398c098ff917dcd9.png](https://img-blog.csdnimg.cn/img_convert/d082e058301600a9398c098ff917dcd9.png)
![fd57e08ee5fc30bf6aed6e7b5a3b4938.png](https://img-blog.csdnimg.cn/img_convert/fd57e08ee5fc30bf6aed6e7b5a3b4938.png)
![f5175ac9856a052312c966fac1b24ab2.png](https://img-blog.csdnimg.cn/img_convert/f5175ac9856a052312c966fac1b24ab2.png)
使用eclipse开发Web项目
eclipse连接Tomcat
窗口-首选项-server-runtime-add-apache-tomcat
选择jre(java版本)如果没有就添加要选择的jdk的路径
再在面板里面配置
![880fc5dad41f5756086f94c5470daf0d.png](https://img-blog.csdnimg.cn/img_convert/880fc5dad41f5756086f94c5470daf0d.png)
![281ee3b968707c01c34cb93e114a21f8.png](https://img-blog.csdnimg.cn/img_convert/281ee3b968707c01c34cb93e114a21f8.png)
![3edc61f2eaa217027cbb7170eb85a3f6.png](https://img-blog.csdnimg.cn/img_convert/3edc61f2eaa217027cbb7170eb85a3f6.png)
jsp页面元素
![681203d6fbbf5cf3924713710f1c9c78.png](https://img-blog.csdnimg.cn/img_convert/681203d6fbbf5cf3924713710f1c9c78.png)
一个例子
![3e847b0ecfd24d74e17d8436d07f9fd7.png](https://img-blog.csdnimg.cn/img_convert/3e847b0ecfd24d74e17d8436d07f9fd7.png)
![d7020304676745b1392a1b32207acff1.png](https://img-blog.csdnimg.cn/img_convert/d7020304676745b1392a1b32207acff1.png)
关于回车
![8108688a7e38d090e654dd3f85843346.png](https://img-blog.csdnimg.cn/img_convert/8108688a7e38d090e654dd3f85843346.png)
![7f542aef0194ce71cab89de6a4dcfc6a.png](https://img-blog.csdnimg.cn/img_convert/7f542aef0194ce71cab89de6a4dcfc6a.png)
关于<%@ page%>
![f9593edd113542bac10baa844142d1b0.png](https://img-blog.csdnimg.cn/img_convert/f9593edd113542bac10baa844142d1b0.png)
关于注释
![a88bb89dc822d5c36cf264ab3252b54c.png](https://img-blog.csdnimg.cn/img_convert/a88bb89dc822d5c36cf264ab3252b54c.png)