一小段jsp代码

<%@ page language="java" contentType="text/html; charset=GBK"
	pageEncoding="GBK"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>args</title>
</head>
<%
	String bgColor = request.getParameter("bgColor");
	boolean hasExplicitColor;
	if (bgColor != null) {
		hasExplicitColor = true;
	} else {
		hasExplicitColor = false;
		bgColor = "WHITE";
	}
%>

<!--jsp 脚本写在html中-->
<body BGCOLOR="<%=bgColor%>">
	<script type="text/javascript">
	<!--jsp脚本写在js中 -->
		var x =
	<%out.println(25);%>
		
	<%out.println("var xx=10");%>
		alert(x);
		alert(xx);
	</script>

	<%
		int xxx = 20;
	%>
	<script type="text/javascript">
		alert(
	<%=xxx%>
		);
	</script>


	<H2 ALIGN="CENTER">Color Testing</H2>
	<!--前台注释的作用:  <%System.out.println("服务器端内容");
			out.print("客户端输出内容");%> -->
	<%
		if (hasExplicitColor) {
			out.println("You supplied an explicit background color of "
					+ bgColor + ".");
		} else {
			out.println("Using default background color of WHITE. "
					+ "Supply the bgColor request attribute to try "
					+ "a standard color, an RRGGBB value, or to see "
					+ "if your browser supports X11 color names.");
		}
	%>
</body>
</html>

posted on 2012-07-07 00:06  java课程设计  阅读(154)  评论(0编辑  收藏  举报

导航