Hi All,
I am developing a small web application in Eclipse. I have trouble showing up Arraylist in JSP.
Whenever i try to list all users in database on web page page, it takes lot of time to load home page and then server gives me some OutOfMemory error as
Exception in thread "ContainerBackgroundProcessor[StandardEngine[Catalina]]" Exception in thread "http-bio-8080-exec-3" java.lang.OutOfMemoryError: Java heap space
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:116)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1374)
at org.apache.catalina.core.StandardWrapper.backgroundProcess(StandardWrapper.java:704)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1530)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1519)
at java.lang.Thread.run(Unknown Source)
java.lang.OutOfMemoryError: Java heap space
In my Home.java servlet, what i want to do is, when user clicks on ListMembers link, the site should take him to ListUser.jsp. But code is getting stuck here somewhere.
Here is my servlet code:
public class Home extends HttpServlet {
private static final long serialVersionUID = 1L;
String varshowusername;
List<User> userslist = new ArrayList<User>();
Saveuserdata objsaveuserdata = new Saveuserdata();
public Home() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
varshowusername=(String) request.getSession().getAttribute("CurrentLoggedInUser");
userslist= objsaveuserdata.getallusers();
request.getSession().setAttribute("UserList", userslist);
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<TITLE>Home</TITLE>");
out.println("<HEAD>");
out.println("<link rel=stylesheet type=text/css href=/mypractice/css/mystyle1.css></link>");
out.println("</HEAD>");
out.println("<BODY>");
out.println("<p>");
out.println("Welcome! This is your Home Page");
out.print("<br>");
out.print(varshowusername);
out.print("<br>");
out.print("<a href='ListUsers.jsp'>List Members</a>");
request.getRequestDispatcher("ListUsers.jsp").forward(request,response);
out.print("<a href='Logout'>Log Out</a>");
out.println("</p>");
out.println("</BODY>");
out.println("</HTML>");
}
Here is my JSP code:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<table border=1>
<tr>
<td>User Name</td>
</tr>
<tbody>
<c:forEach items="${userslist}" var="users">
<tr>
<td><c:out value="${users.name}" /></td>
</tr>
</c:forEach>
</tbody>
</table>
</body>
</html>
Also, though i have added the jstl1.2.jar to my /WEB-INF/lib, the Eclipse still shows me, Unknown Tag (C:ForEach)
Please help me!!!
I am trying to learn servlets and JSPs.
Also, if you feel some modifications are needed in code, please do suggest!
Thank you in adv.