Home Answers Viewqa Struts how to pass string array from action class to jsp page? pls reply me.

 
 


gopi
how to pass string array from action class to jsp page? pls reply me.
2 Answer(s)      8 months ago
Posted in : Struts

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 Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.