<% @page import= "java.text.SimpleDateFormat"%>
<% @page language= "java" import= "java.util.*, java.awt.*" errorpage= "jsps/error.jsp" pageencoding= "UTF-8"%>
<!--jsp in the Guide package, see above (two ways) jsps/error.jsp set a JSPs folder to write a error.jsp page--
<% @taglib uri= "http://java.sun.com/jsp/jstl/core" prefix= "c"%>
<! DOCTYPE HTML public "-//w3c//dtd HTML 4.01 transitional//en" >
<title>jsp Technology Demo </title>
<body>
<%
Button btn = New button ("test Guide package");
Date d = new Date ();
SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-mm-dd HH:mm:ss");
Out.println (sdf.format (d));
Local variables---in JSP are valid within the underlying function _jspservice ()
String str= "hunan City courtyard";
Pagecontext.setattribute ("name", "page1111");
Request.setattribute ("name", "req22222");
Session.setattribute ("name", "session33333");
Application.setattribute ("name", "app44444");
%>
<%! A METHOD----A member variable or method in a JSP that is Index_jsp.java and _jspservice ()
String Hello () {
Return "hello";
}
%>
<br/>
<c:foreach begin= "0" end= "ten" >
Random output point information ...<br/>
</c:forEach>
<%
Out.println (str); Accessing local variables
OUT.PRINTLN (hello ());//access class member
Exception.getstacktrace (); With exception, You must add the attribute in the page directive: iserrorpage= "true"
string res = (string) Pagecontext.findattribute ("name");//from: pagecontext,request,session,applicat These 4 containers from small to large to read the properties
Out.println (res);
String res2 = (string) Pagecontext.findattribute ("name2");//if The attribute is not in 4 containers, the output: null
Out.println (res2);//null
%>
<br/>
ooooo:${name}
kkkkk:${name2} <!--if The property does not exist in 4 containers, Nothing is output (null is not output)--
<br/>
<!--fast output, Small details:%= Two next to each other, do not add ";" at the End. --
<%=str+ "2222"%>
<%=str+ "3333"%>
<%
The following is used to test the Erropage property
int i = 100/0;
%>
</body>
Jsp----write Java code (variables and function Methods) in the JSP