JSP入门学习
来源:互联网 发布:淘宝apple store 编辑:程序博客网 时间:2024/06/06 16:29
JSP语法:
JSP模板元素、JSP表达式、JSP脚本片断、JSP注释、JSP指令、JSP标签、JSP内置对象。
JSP模板元素:
JSP页面中的HTML内容称之为JSP模板元素。
JSP模板元素定义了网页的基本骨架,即定义了页面的结构和外观。
JSP脚本表达式:
JSP脚本表达式(expression)用于将程序数据输出到客户端语法:<%=变量或表达式%>
举例:当前日期:<%=new java.util.Date()%>
JSP引擎在翻译脚本表达式时,会将程序数据转成字符串,然后在相应位置用out.print(....),,将数据输给客户端;
JSP脚本表达式中的变量或表达式后面不能有分号(;)。
下面是在JSP中写的代码:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'chengfakoujue.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
-----------------------------------------------------------------------------------------------------------------------------------
下面是写的三个题:
</head>
<body>
<div>
<div>
<h1>
打印出乘法口诀
</h1>
<hr color="red">
</div>
<div>
<%
for (int row = 1; row <= 9; row++) {
for (int col = 1; col <= row; col++) {
%>
<%=col%>*<%=row%>=<%=row * col%>
<%
}
%>
<br>
<%
}
%>
</div>
<div>
<h1>
三角形
</h1>
<hr color="red">
</div>
<div>
<%
for (int i = 1; i <= 9; i++) {
for (int j = 10; j >= i; j--) {
%>
<%=" "%>
<%
}
%>
<%
for (int x = 1; x <= i; x++) {
%>
<%="* "%>
<%
}
%>
<br>
<%
}
%>
<div>
<hr color="red">
<h3>
水仙花数
</h3>
<%
for (int i = 100; i < 999; i++) {
int x, s, y;
x = i / 100;
s = (i - x * 100) / 10;
y = i - x * 100 - s * 10;
if (i == y * y * y + s * s * s + x * x *x) {
%>
<%=i%>
<%
}
%>
<%
}
%>
</div>
</div>
</div>
</body>
</html>
- 学习经验,JSP入门
- JSP入门学习
- JSP入门学习经验
- jsp入门学习
- jsp入门学习2
- Jsp入门学习1
- jsp Servlet基础入门学习
- JSP学习--web开发入门
- JavaWeb学习六(jsp入门)
- jsp Servlet基础入门学习(1)
- jsp Servlet基础入门学习(2)
- Servlet/JSP学习笔记(4)-Servlet入门
- JSP学习笔记01-MyEclipse入门
- Servlet/JSP学习笔记(4)-Servlet入门
- java学习【web基础-JSP入门】
- JSP入门学习总结(一)JSP常用的标签
- jsp入门
- JSP入门
- 常用Intent
- man 如何显示彩色字符
- Linux常用命令—文件搜索命令(下)
- linux上有用的工具总结
- Log4J用法详解
- JSP入门学习
- watchersetuputil 未定义
- 常用广播动作
- 学习linux内核的经典书籍介绍
- poj 1753
- 设置Android输入法的回车键
- zoj 3460
- http://acm.nyist.net/JudgeOnline/problem.php?pid=13
- 【屠夫科普】感染PE增加导入项实现注入