JSP day 1

来源:互联网 发布:五十知天命六大而耳顺 编辑:程序博客网 时间:2024/05/29 17:04

JSP 教程:

 http://www.w3cschool.cc/jsp/jsp-tutorial.html


分析案例一:

deliveryin.jsp;


  <%@page contentType="text/html"%>
<html>
<head><title>Deliver In</title></head>
<body>
<jsp:include page="header.html" flush="true"/>
<script language="JAVASCRIPT">
function checkData() {
        document.scanForm.submit();
        return true;
}
</script>
<br>
<h2>Please enter serial numbers and pick location, logop</h2>
<form name='scanForm' action='deliverinresults.jsp' METHOD='POST'>      <%-- 数据如何提交?  POST --%>

 

       deliverinresults.jsp

<%@ page language="java" import="java.net.Socket,com.sun.wwops.tie.mint.tools.*"%>
<html>
<head><title>Deliver In</title></head>
<body>
<jsp:include page="header.html" flush="true"/>


<% out.flush();                       <%-- out.flush() 通过查询,为缓冲区的内容输出到客户端浏览器 --%> 
   com.sun.wwops.tie.mint.controller.DeliverInController ctr = new com.sun.wwops.tie.mint.controller.DeliverInController();        <%-- ????--%>
   ctr.deliverIn( request, response, out );
%>

</body>
</html>


语法格式定义:

<jsp:scriptlet>   代码片段</jsp:scriptlet>
或者

 <% 代码片段 %>


第一个程序:

 <head><title>Hello World</title></head>

<body>Hello World!<br/><%out.println("Your IP address is " + request.getRemoteAddr());%></body></html>

变量声明

<%! declaration; [ declaration; ]+ ... %>

例:

<%! int i = 0; %> 

<%! int a, b, c; %> 

<%! Circle a = new Circle(2.0); %>

表达式

<%= 表达式 %> or <jsp:expression> 表达式 </jsp:expression>
例:
<html> 
<head><title>A Comment Test</title></head> 
<body><p>   Today's date: <%= (new java.util.Date()).toLocaleString()%></p></body> </html> 


0 0
原创粉丝点击