0
我是JSP新手。这是我简单的JSP文件:jspInit()和其他方法如何在Glassfish 4.0的JSP上工作?
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.util.Date"%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%!public void jspInit() {
System.out.println("Init called!");
}%>
<h3>Hello World!</h3>
<br />
<%
int i;
for (i = 0; i < 100; i++)
out.print(i + " ");
out.println("èéòçàù<br/>");
%>
<b>The time right now is: <%=new Date()%></b>
<%
if (request.getParameter("name") != null) {
session.setAttribute("name", request.getParameter("name"));
application.setAttribute("name", request.getParameter("name"));
}
%>
<br />
<b>The name that was set for request is: <%=request.getParameter("name")%></b>
<br />
<b>The name that was set for session is: <%=session.getAttribute("name")%></b>
<br />
<b>The name that was set for application is: <%=application.getAttribute("name")%></b>
<br />
</body>
</html>
jspInit()
方法在每次打开我的页面时调用。不应该只在第一次打开页面时调用它?有人可以告诉我其他JSP方法是什么,它们是如何工作的?我找不到这方面的确切信息。谢谢!