1
--------------
<%
string msg="this is a (sun企业级应用的首选) test";
out.print("hello world");
%>//java模块 申明msg为字符串变量
--------------
<%=msg%>
//输出变量2 在客户端的源代码中显示注释:
//
<%
string msg="我是tomcat(一个很好用的jsp运行平台)";
out.print("hello world");
%>
<%=msg%>
3 隐藏注释
<%@page language="java"%>//客户端看不到注释
<%
string msg="我是tomcat(一个很好用的jsp运行平台)";
out.print("hello world");
%>
<%=msg%>
4 声明变量,方法和新的类
<%@page language="java"%>
<%!
public class university
{
string name,city;
university(string name,string city)
{
this.name=name;
this.city=city;
}
public string getname()
{
return name;
}
public string getcity()
{
return city;
}
}
%>
<%
university university1=new university("山东科技大学","青岛市");
university university2=new university("山东大学","济南市");
out.println("第一所大学是:");
out.println(university1.getname() "
");
out.println(university1.getcity() "
");
out.println("第二所大学是:");