Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass a 2D Array from one JSP to another

Status
Not open for further replies.

ilarum

Programmer
Aug 25, 2003
13
DE
Hi,
I have a JSP page that has a 2D Array of Strings. I need to pass this 2D Array to another JSP. But when I pass its a null. The code is as follows

<html>
<body>
<from method = &quot;post&quot; action = &quot;two.jsp&quot;>

<% String[][] data = {{&quot;USER&quot;, &quot;TOM&quot;}, {&quot;EMAIL&quot;, &quot;tom@xyz.com&quot;}};
%>
<%
session.setAttribute(&quot;MyData&quot;, data);
%>
<input type = &quot;submit&quot; value = &quot;Click&quot;>
</form>
</body>
</html>

The code of two.jsp is as follows

<%
String[][] data = session.getAttribute(&quot;MyData&quot;);
%>
<% for(int i = 0; i < data.length; i++)
{
for(int j = 0; j < data[0].length; j++)
System.out.print(&quot; Name/Value &quot; + data[j]);
System.out.println();

}
%>

It throws a null pointer Excpetion at the line data.length.

Could anybody say me why.

With Regards
Murali
But it does now worl
 
<%
String[][] data = session.getAttribute(&quot;MyData&quot;);
%>
Why don't try casting your value at first???

Salih Sipahi
Software Engineer.
City of Istanbul Turkey
s.sipahi@sahinlerholding.com.tr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top