how to pass string array from action class to jsp page? pls reply me.

how to pass string array from action class to jsp page? pls reply me.

View Answers

September 10, 2012 at 5:24 PM

You can use session.setAttribute() and session.getAttribute() methods. In your action class,

String[] arr = {"A","B","C","D"};
for (int x = 0; x < arr .length; x++) {
out.println(arr[x]);
}
session.setAttribute("names", arr);

And through your jsp page, get array values.

<%
try {

String[] str = (String[]) session.getAttribute("names");

for (int x = 0; x < str.length; x++) {
out.println(str[x]);
}

} catch (Exception e) {
out.println(e);
}
%>

September 10, 2012 at 5:35 PM

but, we can not use java code in jsp. with out using java code in jsp, is it possible?









Related Tutorials/Questions & Answers:
Advertisements