javaweb

一.学习的内容
1.JSP基本语法
(1)jsp脚本语法
(2)jsp声明语句
(3)jsp表达式
(4)jsp注释
2.jsp指令
(1)page指令
(2)include指令
3.jsp隐式对象(有九个)
3.代码实现:
(1)

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ page import="java.util.Date" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
data.jsp
<%out.printn(new Date().toGMTString()); %>
</body>
</html>

(2)

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%!
int a=1;
int b=3;
%>
<%!
public String daying(){
	String str="dashuju2003";
	return str;
}
%>
<%out.print("biaoda:" +a+b); %>
<br/>
<br/><br/>
<%out.print(daying()); %>
<br/><br/>
</body>
</html>

(3)

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<!-- html注释 -->
<%
System.out.print("java 注释");
%>
<%-- jsp注释 --%>;
</body>
</html>

(4)

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
out.print("frist line<br/>");
response.getWriter().print("second line<br/>");
%>
</body>
</html>

(5)

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<% 
 HttpServletRequest req=(HttpServletRequest)pageContext.getRequest();
pageContext.setAtteribute("req11","PAGE_SCOPE",pageContext.PAGE_SCOPE);
pageContext.setAtteribute("req22","PAGE_SCOPE",pageContext.PAGE_SCOPE);
pageContext.setAtteribute("req33","PAGE_SCOPE",pageContext.PAGE_SCOPE);
pageContext.setAtteribute("req","PAGE_SCOPE",pageContext.PAGE_SCOPE);
%>
<%=pageContext.findAttribte("req") %>
<hr/>
<%=(String)req.getAttribute("req") %>
</body>
</html>

(6)

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>欢迎您</title>
</head>
<body>
欢迎您,现在时间是:
<%@ include file="data .jsp" %>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值