S
Steve Burrus
I need some help/assistance from someone with this problem of mine of
trying to get a jsp which displays a table with some table data in it,
i.e., some of my favorite movies, to interact successfully with a
servlet!!! Now, in the servlet, I have used--probably for the very 1st
time ever--the servlet method "RequestDispatcher" and both of the
getAttribute() and the setAttribute() methods, but alas, when I try to
view the jsp in my web browser, I only get the jsp title showing!!! Now
whasssssssssup with that anyway???!!
Here is first my servlet code :
/* Here is a particular servlet which is used with a jsp that will
* print out a movie list.
*/
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class MovieServlet extends HttpServlet {
public void service (HttpServletRequest request, HttpServletResponse resp)
throws IOException, ServletException {
PrintWriter out = resp.getWriter();
String [] movieList = { "Patton", "Some Like It Hot", "Bank
Shot","Beyond Atlantis", "Titanic"};
java.util.List mymovie = new java.util.ArrayList();
mymovie.add(movieList);
request.setAttribute("movieList", mymovie);
String[] items = (String[]) request.getAttribute("movieList");
for(int i = 0; i < items.length; i++){
String movie = items;
out.println(movie);
}
RequestDispatcher steve = request.getRequestDispatcher("mymovies.jsp");
steve.forward(request, resp);
}
}
and then my jsp code :
<%@ taglib prefix = "c" uri="http://java.sun.com/jsp/jstl/core" %>
<html><head>
</head><body>
<b><i>My Personal Movie List</b></i><br><br><br>
<table>
<c:forEach var = "movie" items = "${movieList}"varStatus =
"movieLoopCount"> >
<tr>
<td>Count : ${movieLoopCount.count}</td>
</tr>
<tr>
<td>${movie}</td>
</tr>
<tr><td>Patton</td></tr>
</c:forEach>
</table>
</body></html>
trying to get a jsp which displays a table with some table data in it,
i.e., some of my favorite movies, to interact successfully with a
servlet!!! Now, in the servlet, I have used--probably for the very 1st
time ever--the servlet method "RequestDispatcher" and both of the
getAttribute() and the setAttribute() methods, but alas, when I try to
view the jsp in my web browser, I only get the jsp title showing!!! Now
whasssssssssup with that anyway???!!
Here is first my servlet code :
/* Here is a particular servlet which is used with a jsp that will
* print out a movie list.
*/
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class MovieServlet extends HttpServlet {
public void service (HttpServletRequest request, HttpServletResponse resp)
throws IOException, ServletException {
PrintWriter out = resp.getWriter();
String [] movieList = { "Patton", "Some Like It Hot", "Bank
Shot","Beyond Atlantis", "Titanic"};
java.util.List mymovie = new java.util.ArrayList();
mymovie.add(movieList);
request.setAttribute("movieList", mymovie);
String[] items = (String[]) request.getAttribute("movieList");
for(int i = 0; i < items.length; i++){
String movie = items;
out.println(movie);
}
RequestDispatcher steve = request.getRequestDispatcher("mymovies.jsp");
steve.forward(request, resp);
}
}
and then my jsp code :
<%@ taglib prefix = "c" uri="http://java.sun.com/jsp/jstl/core" %>
<html><head>
</head><body>
<b><i>My Personal Movie List</b></i><br><br><br>
<table>
<c:forEach var = "movie" items = "${movieList}"varStatus =
"movieLoopCount"> >
<tr>
<td>Count : ${movieLoopCount.count}</td>
</tr>
<tr>
<td>${movie}</td>
</tr>
<tr><td>Patton</td></tr>
</c:forEach>
</table>
</body></html>