EL
<%@ page contentType="text/html;charset=utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page import="com.fastcampus.app.*" %>
<%
Person person = new Person();
request.setAttribute("person", person);
request.setAttribute("name", "kim");
request.setAttribute("list", new java.util.ArrayList());
%>
<html>
<head>
<title>EL</title>
</head>
<body>
person.getCar().getColor()=<%=person.getCar().getColor()%> <br>
person.getCar().getColor()=${person.getCar().getColor()} <br>
person.getCar().getColor()=${person.car.color} <br>
name=<%=request.getAttribute("name")%> <br>
name=${requestScope.name} <br>
name=${name} <br>
id=<%=request.getParameter("id")%> <br>
id=${pageContext.request.getParameter("id")} <br>
id=${param.id} <br>
"1"+1 = ${"1"+1} <br>
"1"+="1" = ${"1"+="1"} <br>
"2">1 = ${"2">1} <br>
null = ${null}<br>
null+1 = ${null+1} <br>
null+null = ${null+null} <br>
"" + null = ${""+null} <br>
""-1 = ${""-1} <br>
empty null=${empty null} <br>
empty list=${empty list} <br>
null==0 = ${null==0} <br>
null eq 0 = ${null eq 0} <br>
name == "kim"=${name=="kim"} <br>
name != "kim"=${name!="kim"} <br>
name eq "kim"=${name eq "kim"} <br>
name ne "kim"=${name ne "kim"} <br>
name.equals("kim")=${name.equals("kim")} <br>
</body>
</html>
[실행결과]
person.getCar().getColor()=red
person.getCar().getColor()=red
person.car.color=red
name=kim
name=kim
name=kim
id=asdf
id=asdf
id=asdf
"1"+1 = 2
"1"+="1" = 11
"2">1 = true
null =
null+1 = 1
null+null = 0
"" + null = 0
""-1 = -1
empty null=true
empty list=true
null==0 = false
null eq 0 = false
name == "kim"=true
name != "kim"=false
name eq "kim"=true
name ne "kim"=false
name.equals("kim")=true5
jsp 가 서블릿 파일과 클래스 파일로 변환 과정
C:\sts3\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\app\org\apache\jsp
el.jsp.java
public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
throws java.io.IOException, javax.servlet.ServletException {
if (!javax.servlet.DispatcherType.ERROR.equals(request.getDispatcherType())) {
final java.lang.String _jspx_method = request.getMethod();
if ("OPTIONS".equals(_jspx_method)) {
response.setHeader("Allow","GET, HEAD, POST, OPTIONS");
return;
}
if (!"GET".equals(_jspx_method) && !"POST".equals(_jspx_method) && !"HEAD".equals(_jspx_method)) {
response.setHeader("Allow","GET, HEAD, POST, OPTIONS");
response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "JSP들은 오직 GET, POST 또는 HEAD 메소드만을 허용합니다. Jasper는 OPTIONS 메소드 또한 허용합니다.");
return;
}
}
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\n");
out.write("\r\n");
out.write("\r\n");
out.write("\r\n");
Person person = new Person();
request.setAttribute("person", person);
request.setAttribute("name", "kim");
request.setAttribute("list", new java.util.ArrayList());
out.write("\r\n");
out.write("<html> \r\n");
out.write("<head> \r\n");
out.write(" <title>EL</title> \r\n");
out.write("</head> \r\n");
out.write("<body> \r\n");
out.write("person.getCar().getColor()=");
out.print(person.getCar().getColor());
out.write(" <br>\r\n");
out.write("person.getCar().getColor()=");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${person.getCar().getColor()}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write(" <br>\r\n");
out.write("person.getCar().getColor()=");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${person.car.color}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write(" <br> \r\n");
out.write("name=");
out.print(request.getAttribute("name"));
out.write(" <br> \r\n");
out.write("name=");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${requestScope.name}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write(" <br>\r\n");
out.write("name=");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${name}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write(" <br>\r\n");
out.write("id=");
out.print(request.getParameter("id"));
out.write(" <br>\r\n");
out.write("id=");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${pageContext.request.getParameter(\"id\")}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write(" <br>\r\n");
out.write("id=");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${param.id}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write(" <br>\r\n");
out.write("\"1\"+1 = ");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${\"1\"+1}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write(" <br>\r\n");
out.write("\"1\"+=\"1\" = ");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${\"1\"+=\"1\"}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write(" <br>\r\n");
out.write("\"2\">1 = ");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${\"2\">1}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write(" <br> \r\n");
out.write("null = ");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${null}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write("<br>\r\n");
out.write("null+1 = ");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${null+1}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write(" <br>\r\n");
out.write("null+null = ");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${null+null}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write(" <br>\r\n");
out.write("\"\" + null = ");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${\"\"+null}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write(" <br> \r\n");
out.write("\"\"-1 = ");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${\"\"-1}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write(" <br> \r\n");
out.write("empty null=");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${empty null}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write(" <br>\r\n");
out.write("empty list=");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${empty list}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write(" <br>\r\n");
out.write("null==0 = ");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${null==0}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write(" <br>\r\n");
out.write("null eq 0 = ");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${null eq 0}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write(" <br>\r\n");
out.write("name == \"kim\"=");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${name==\"kim\"}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write(" <br>\r\n");
out.write("name != \"kim\"=");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${name!=\"kim\"}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write(" <br>\r\n");
out.write("name eq \"kim\"=");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${name eq \"kim\"}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write(" <br> \r\n");
out.write("name ne \"kim\"=");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${name ne \"kim\"}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write(" <br> \r\n");
out.write("name.equals(\"kim\")=");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${name.equals(\"kim\")}", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null));
out.write(" <br> \r\n");
out.write("</body>\r\n");
out.write("</html>\r\n");
out.write("\r\n");
out.write("[실행결과]\r\n");
out.write("person.getCar().getColor()=red\r\n");
out.write("person.getCar().getColor()=red\r\n");
out.write("person.car.color=red\r\n");
out.write("name=kim\r\n");
out.write("name=kim\r\n");
out.write("name=kim\r\n");
out.write("id=asdf\r\n");
out.write("id=asdf\r\n");
out.write("id=asdf\r\n");
out.write("\"1\"+1 = 2\r\n");
out.write("\"1\"+=\"1\" = 11\r\n");
out.write("\"2\">1 = true\r\n");
out.write("null =\r\n");
out.write("null+1 = 1\r\n");
out.write("null+null = 0\r\n");
out.write("\"\" + null = 0\r\n");
out.write("\"\"-1 = -1\r\n");
out.write("empty null=true\r\n");
out.write("empty list=true\r\n");
out.write("null==0 = false\r\n");
out.write("null eq 0 = false\r\n");
out.write("name == \"kim\"=true\r\n");
out.write("name != \"kim\"=false\r\n");
out.write("name eq \"kim\"=true\r\n");
out.write("name ne \"kim\"=false\r\n");
out.write("name.equals(\"kim\")=true5");
} catch (java.lang.Throwable t) {
if (!(t instanceof javax.servlet.jsp.SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
try {
if (response.isCommitted()) {
out.flush();
} else {
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);
}
'Spring > Ch2. Spring MVC' 카테고리의 다른 글
Spring MVC - Filter (0) | 2022.09.17 |
---|---|
Spring MVC - JSTL(JSP Standard Tag Library) (0) | 2022.09.17 |
Spring MVC - 유효 범위(scope)와 속성(attribute) (0) | 2022.09.17 |
Spring MVC - JSP, Servlet (0) | 2022.09.16 |
Spring MVC - servlet-context.xml (0) | 2022.09.16 |