欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

JSP中隐式对象用法实例

程序员文章站 2023-08-24 16:11:55
本文实例讲述了jsp中隐式对象用法。分享给大家供大家参考,具体如下: <%@ page language="java" import="java.util....

本文实例讲述了jsp中隐式对象用法。分享给大家供大家参考,具体如下:

<%@ page language="java" import="java.util.*" pageencoding="utf-8"%>
<%
string path = request.getcontextpath();
string basepath = request.getscheme()+"://"+request.getservername()+":"+request.getserverport()+path+"/";
%>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en">
<html>
 <head>
 <base href="<%=basepath%>">
 <title>my jsp 'demo1.jsp' starting page</title>
 <meta http-equiv="pragma" content="no-cache">
 <meta http-equiv="cache-control" content="no-cache">
 <meta http-equiv="expires" content="0"> 
 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
 <meta http-equiv="description" content="this is my page">
 <!--
 <link rel="stylesheet" type="text/css" href="styles.css">
 -->
 </head>
 <body>
 <% 
  date date=new date();
  out.write(date.tolocalestring()+"<br/>");
 %>
 <%
  //域之间的信息获取
  request.setattribute("data", "abc");//request的域
  string data=(string)pagecontext.getattribute("data", pagecontext.request_scope);//用pagecontext域获取request域的内容
  out.write(data+"<br/>");
  string data2=(string)pagecontext.findattribute("data");//直接寻找data
  out.write(data2+"<br/>");
 %>
 ${data}<!-- 正则表达式 -->
 <!-- 
  <jsp:forward page="/1.jsp"></jsp:froward>//配置首页时跳转到servlet
  <jsp:include page="/1.jsp"></jsp:include><%--pagecpntext.include()动态包含--%>
  //携带参数
  <jsp:forward page="/1.jsp">
   <jsp:param name="data" value="data"></jsp:param>
  </jsp:froward>
 -->
 </body>
</html>

希望本文所述对大家jsp程序设计有所帮助。