JSP编程实践一

966阅读 0评论2009-10-16 hkebao
分类:Java

1.页面a.jsp有异常抛到error.jsp页面显示我是用
JSP设置值与JSTL读取值 或是JSTL设置值然后通过JSP来读取
<%
String newImg="yes";
request.setAttribute("newImg",newImg); //设置
%>
${newImg} //读取

//设置
${newImg1} //读取
<%= pageContext.getAttribute("newImg1")%> //读取

统计的错误页面代码:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" isErrorPage = "true"%>
<%@ taglib prefix="c" uri="" %>
<% pageContext.setAttribute("error",exception.getMessage()); %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


 
   
    错误页面
   
   
 
   
    使用JSTL  + EL标签
 


现在的全部页面JSP都是用JSTL+EL标签实现的!
OK!


上一篇:JSP内置对象整理
下一篇:结合实例学习httpclient包