before using this JSP, you need to write a Stu class to generate the set and get methods.
Public Class stu{
private int id;
private String name;
public void setId (int id) {
this.id=id
}
public int getId () {return
this.id;
}
public void SetName (String name) {
This.name=name
}
Public String GetName () {return
this.name
}}
Write a simple servlet.
public class Gotomall extends HttpServlet {public
void doget (HttpServletRequest request, HttpServletResponse Response)
throws Servletexception, IOException {arraylist<stu> stus=new
();
Stu stu1=new Stu ();
Stu1.setid (1);
Stu1.setname ("AA");
Stu2.setid (2);
Stu2.setname ("BB");
Stus.add (STU1);
Stus.add (STU2);
Request.setattribute ("Stus", stus);
Request.getrequestdispatcher ("/web-inf/admin/my.jsp"). Forward (request, response);
public void DoPost (HttpServletRequest request, httpservletresponse response)
throws Servletexception, IOException {
this.doget (request, response);
}
}
my.jsp
<%@ page language= "java" import= "java.util.*" pageencoding= "Utf-8"%> <!-- Introduce JSTL tag library--> <%@ taglib uri= "Http://java.sun.com/jsp/jstl/core" prefix= "C"%> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">