<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%
int i = 25;
%>
My JSP 'index.jsp' starting page
<%--
这是JSP注释
--%>
<%
int j = 2;
%>
Test JSP Page
<%
System.out.println(i/j);
%>
public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
throws java.io.IOException, javax.servlet.ServletException {
final javax.servlet.jsp.PageContext pageContext;
javax.servlet.http.HttpSession session = null;
final javax.servlet.ServletContext application;
final javax.servlet.ServletConfig config;
javax.servlet.jsp.JspWriter out = null;
final java.lang.Object page = this;
javax.servlet.jsp.JspWriter _jspx_out = null;
javax.servlet.jsp.PageContext _jspx_page_context = null;
try {
response.setContentType("text/html; charset=UTF-8");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
out.write('\r');
out.write('\n');
int i = 25;
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
out.write(" \r\n");
out.write(" \r\n");
out.write(" My JSP 'index.jsp' starting page \r\n");
out.write("\t\r\n");
out.write("\t\r\n");
out.write("\t");
out.write("\r\n");
out.write(" \r\n");
out.write(" ");
int j = 2;
out.write("\r\n");
out.write(" \r\n");
out.write(" Test JSP Page
\r\n");
out.write(" \r\n");
out.write(" ");
System.out.println(i/j);
out.write("\r\n");
out.write("\r\n");
} catch (java.lang.Throwable t) {
if (!(t instanceof javax.servlet.jsp.SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
try { out.clearBuffer(); } catch (java.io.IOException e) {}
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
else throw new ServletException(t);
}
} finally {
_jspxFactory.releasePageContext(_jspx_page_context);
}
}
所以,各个代码块之间间隔的的其他html代码或注释对java代码毫无影响.(在代码块中可以写java注释...而且会被编译进Java文件中)
结果会直接在页面上输出100.