I am trying to display the note attribute that I saved into my request.setAttribute("entries", entries)
, but I can't access this data in my jsp
and I can't figure it out. I've tried {note}
, but that doesn't work.
This is my controller class:
while( rs.next() )
{
int id = rs.getInt("id");
String name = rs.getString("name");
String note = rs.getString("note");
String title = rs.getString("title");
Notes entry = new Notes(id, name, note, title);
entries.add(entry);
}
request.setAttribute("entries", entries);
request.getRequestDispatcher( "/WEB-INF/homework2/MyNotes.jsp" ).forward(
request, response );
}
catch( SQLException e )
{
throw new ServletException( e );
}
finally
{
try
{
if( c != null ) c.close();
}
catch( SQLException e )
{
throw new ServletException( e );
}
}
}
}
This is my jsp
view:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>MyNotes</title>
</head>
<body>
<p align="right">Hello, ${sessionScope.CurrentUser}! <a href="Logout">Logout</a></p>
<span>JOT <a href="MyNotes">My Notes</a> | <a href="NewNote.jsp">New</a></span>
<br>
<br>
<br>
<p>${note} </p>
<p>${applicationScope.entries.note},</p>
</body>
</html>