replace JSP scriplet code

replace JSP scriplet code with JSTL Tags
--
JSP scriplet code:

<%@ page import="java.util.*, com.luv2code.web.jdbc.*" %>



    Student Tracker App
    
    

<%
    // get student from the request object (sent by servlet)
    List theStudents = 
                (List) request.getAttribute("STUDENT_LIST");
    
%>

    
<% for (Student tempStudent: theStudents) { %> <% } %>
First Name Last Name Email
<%= tempStudent.getFirstName() %> <%= tempStudent.getLastName() %> <%= tempStudent.getEmail() %>

--
replace it with JSTL Tags

  • 首先检查,library里面有jsp.jstl 和jsp.jstl-api 这两个jar文件,如图:
replace JSP scriplet code_第1张图片
image.png
  • 检查完之后修改list-students.jsp 代码如下:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>




    Student Tracker App
    
    



    
First Name Last Name Email
${tempStudent.firstName} ${tempStudent.lastName} ${tempStudent.email}

你可能感兴趣的:(replace JSP scriplet code)