jsp一些重点及注意

1、这个jsp文件是前后都不能有空格及其他的语句。

<%
response.getWriter();
RequestDispatcher rd = application
.getRequestDispatcher("/JiuBiao.html");
rd.forward(request, response);
%>


2、写的page文件:

<%@ page contentType="text/html" pageEncoding="GB2312"%>
<%
PageContext lastpageContext = null;
int count = 0;
%>
<%
if (count != 0) {
if (lastpageContext == pageContext) {
out.println("本次与上次的pageContext对象相同<br>");
} else {
out.println("本次与上次的pageContext对象不同<br>");
}
String x = (String) pageContext.getAttribute("x");
if ("abc".equals(x)) {
out.println("获取本次pageContext的属性值<br>");
} else {
out.println("没有获取本次的pageContext的属性值<br>");
}
}
lastpageContext = pageContext;
pageContext.setAttribute("x", new String("abc"));
count++;
System.out.println(count);
%>


3、java.lang.IllegalStateException异常发生的原因:

      因为Application Server在处理编译jsp时对于<%和%>之间的内容通过PrintWriter输出(包括HTML标签,空格,回车等通过浏览器生成的标识符),但是jsp文件内容又要进行流输出:ServletOutputStream,这样做相当于试图在Servlet中使用两种输出机制,就会发生java.lang.IllegalStateException异常。


4、jsp九大隐式对象

public void _jspService(HttpServletRequest request,
HttpServletResponse response)
throws java.io.IOException, ServletException
{
JspFactory _jspxFactory = null;
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
...
...
Throwable exception =
org.apache.jasper.runtime.JspRuntimeLibrary.getThrowable(request);
if (exception != null) {
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值