Originally posted by Tang Yue:
Given the folowing code within a JSP page
Why ${requestScope.noises} isn't a correct answer? Although noises is an array, can't EL automatically call the toString() of this array?
It's returning Exactly what's returned by toString() of this array. Instead you can try this ...
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%String name[] = new String[]{"Noisy Place"}; %>
<c:set var="noises" value="<%=name %>" scope="request"/>
It's a ${requestScope.noises[0]}
</body>
</html>
don't forget to include jstl.jar & standard.jar in your classpath.
hope this will help.
Regards