当前位置:网站首页>Dynamic Web Development Fundamentals

Dynamic Web Development Fundamentals

2022-08-10 03:59:00 Tangerineꦿ.๓

URL

Uniform Resource Location 统一资源定位符
补充内容 URL统一资源定位符URI的子集
URI统一资源标记符
URL的组成

 

There are two types of protocol parts:httphttps
http协议:超文本传输协议,It is a specification for data transmission

Tomcat服务器简介

服务器webLogicwebSphereJBossJettyTomcat....
作者Apache
作用:应用服务器

 

安装tomcat之前,Make sure to have it installed and configured on your computerJDK,因为tomcat运行依赖
JRE

配置Tomcat环境变量

1.新建变量名:CATALINA_BASE,变量值:D:\ruanjian\apache-tomcat- 7.0.79
2.新建变量名:CATALINA_HOME,变量值:D:\ruanjian\apache-tomcat- 7.0.79
3.打开PATH,添加变量值: D:\ruanjian\apache-tomcat- 7.0.79\bin;D:\ruanjian\apache-tomcat-7.0.79\lib

启动Tomcat服务

CMD命令下输入命令:startup开启
Or in a graphical interface:点击startup.batwindowsSystem start button点击 startup.sh是LinuxSystem start button
shutdown.batwindowsSystem shutdown button点击shutdown.shLinux系统的 关闭按钮

测试Tomcat

打开浏览器,在地址栏中输入http://localhost:8080回车,如果看到Tomcat
带的一个JSP页面,说明你的JDKTomcat已搭建成功.

 Tomcat的端口配置

通过配置文件server.xml修改Tomcat端口号

 注意:修改了配置文件后,一定要重新启动Tomcat,再次访问Tomcat

Web项目的目录结构

 

 通过配置文件web.xmlVisit the start page

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<welcome-file-list>
<welcome-file>index01.html</welcome-file>
<welcome-file>index02.html</welcome-file>
</welcome-file-list>
 <display-name></display-name>
</web-app>

什么是JSP

JSP全称Java Servlet Pages ----->JSP就是一个Servlet 程序
JSP即在HTML代码中嵌入javaA technology that realizes the dynamic display of web pages by code
Servlet 的作用:用javaLanguage development dynamic resource technology
JSP的作用:用java语言(+html语言)开发动态资源的技术
JSP的特点:
1jsp的运行必须交给tomcat服务器(tomcatwork目录存放jspTemporary at runtime
文件)
2jsp页面既可以写html代码也可以写java代码
<%@ page language="java" import="java.util.*,java.text.*" contentType=
"text/html; charset=utf-8" %>
<html>
<head>
<title>第一个Web应用</title>
</head>
<body>
你好,今天是
<% SimpleDateFormat formater=new SimpleDateFormat("yyyy年MM
月dd日");
String strCurrentTime=formater.format(new Date());%>
<%=strCurrentTime%>
</body>
 </html>

JSP中的page指令

jsp指令:page指令、include指令、taglib指令
一个jsp页面中可以包含多个page指令,通常位于jsp页面的顶端,需要注意的是:
page指令只对当前jsp页面有效.
<%@ page
language="java" --告诉服务器使用什么动态语言来翻译jsp文件
import="java.util.*,java.text.*" --告诉服务器java文件使用什么包,between multiple packages
用逗号分隔pageEncoding="utf-8" --告诉服务器使用什么编码翻译jsp文件(java文件)
contentType= "text/html; charset=utf-8" --The server sends the browser the type of data and inside
content encoding
%>
jsp表达式语法<%=Variable or expression or constant%> 作用:Outputs the value or expression of a variable to the browser
The calculated results are similarout.print
jsp脚本语法<%java代码%> 作用:执行java代码
jsp声明语法<%!变量或方法%> 作用:声明js的变量或方法
jsp注释语法<%--jsp注释--%> :HTML的注释will be translated and executed,而jspThe annotations do not
will be translated and executed
Internal comments for the script<% //单行注释 /*多行注释*/ %>
External comments for scripts<%--jsp注释--%>

 

JSP 执行过程 

You can view the build in the published project.class.java文件
D:\ruanjian\apache-tomcat-
7.0.79\work\Catalina\localhost\jsp01\org\apache\jsp\jsp

使用eclipse创建web项目  

 

在eclipse中配置tomcat

第一种:Windows----preferences----Add
第二种:右键项目名——properties——Java Build Path——AddLibrary——server
Runtime——
第三种:右键项目名——properties——Project Facets——Runtimes对勾——
Apply——ok

部署Web项目

 

 

 Web程序的调试与排错

 

课后作业  

一、What are the main differences between dynamic and static web pages?
静态网页和动态网页各有特点,Whether a website adopts dynamic or static pages mainly depends on the function of the website
The amount of demand and website content.如果网站功能比较简单,内容更新量不是很大,Use pure static network
The page way would be simpler,反之一般要采用动态网页技术来实现.
静态网页是网站建设的基础,静态网页和动态网页之间也并不矛盾,For the website to adapt to the search
search engine retrieval needs,即使采用动态网站技术,也可以将网页内容转化为静态网页发布.
动态网站也可以采用静动结合的原则,适合采用动态网页的地方用动态网页,如果有必
To use static web pages,则可以考虑用静态网页的方法来实现,在同一个网站上,within dynamic web pages
It is also common for both content and static web content to coexist

二、请描述B/S架构的特点?

B/S结构中,The browser side and the application server side use the request/响应模式进行交互.
交互的过程如下.
1.The client accepts the user's request;
2.The client sends a request to the application server:The client sends the request message(包含用户名、密码等信息)发送到
应用服务器端,等待服务器端的响应;
3.数据处理:The server side of the application usually uses a server-side scripting language,如JSPASP.Net等,来访问数
据库,获得查询结果;
4.发送响应:The application server sends a response message to the client(Usually generated dynamicallyHTML页面),并
by the user's browser,解释HTML文件,呈现用户界面.

 

三、请描述B/S架构与C/S架构的区别?

维护和升级方式简单.C/S结构的每一个客户端都必须安装和配置软件.If a company has a total of
50个客户站点使用一套C/S结构的软件,Then when the software has undergone even minor changes(比Such as adding a function),The system maintainer should uninstall the original software of the client,Install the new version again,然后进
行设置.由于在B/S结构中,软件应用的业务逻辑完全在服务器端实现,All clients only
是浏览器,根本不需要做任何的维护.所以,软件升级后,The system maintainer just takes the server out of it
Just upgrade the software to the latest version.其他客户端,只要重新登录系统,The latest version is already in use
this software.
用户访问范围更大.C/S是建立在局域网的基础上的,而B/S是建立在Internet的基础上
的,The scope of user access is naturally different

 

原网站

版权声明
本文为[Tangerineꦿ.๓]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/222/202208100252518762.html