I am new to jstl
While trying the following code,i am gettting the items in the
string printed but not the no of parameters in the array
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Main extends HttpServlet implements
Servlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String[] names={"salil verma","amit tripathi","amit pandey","amit singh"};
request.setAttribute("names",names);
RequestDispatcher rd = request.getRequestDispatcher("Main.jsp");
rd.forward(request,response);
}
}
The code for Main.jsp is as follows-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<HTML>
<HEAD>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="IBM Software Development Platform">
<META http-equiv="Content-Style-Type" content="text/css">
<LINK href="theme/Master.css" rel="stylesheet" type="text/css">
<TITLE>Main.jsp</TITLE>
</HEAD>
<BODY>
<p> The attributes in the request are as follows <br>
<c:forEach var="name" items="${names}" varStatus="Count">
<br> ${name}
</c:forEach>
<p> The no of elements in the string array are = ${Count.count}
</BODY>
</HTML>
I get the following as output--
The attributes in the request are as follows
salil verma
amit tripathi
amit pandey
amit singh
The no of elements in the string array are =
But the no of elements are not printed. So can any one help me
