I believe the problem is, you are NOT submitting a form to those links.
Infact, you need to forward to the JSP page for the request to get passed to
it. I am not perfectly sure on this, but I am pretty sure that by using the
<a href=..> tag to link to another page, the request object in the current
JSP page is NOT passed on to the JSP page of a link. You would have to
submit a form to that JSP page in order for the getAttribute() call on that
page to see the attribute of the previous page. Again..not completely sure,
but pretty sure that is how it works.
In order for this to work, you would probably have to do something like:
<a href="receivingPage.jsp?myStringArray=<%= arrayOfString %>">Click
here</a>
Then again..I don't even know if that would work. ;)
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Nathan Jantz
Sent: Tuesday, May 02, 2000 11:00 AM
To: [EMAIL PROTECTED]
Subject: Passing objects from JSP to JSP
Hi all,
I'm interested in being able to pass objects from jsp to jsp using the
setAttribute() and getAttribute() methods without the use of a controller
servlet or bean but have been unsuccessful. Here is some code that I have
tried:
callingPage.jsp:
<%
String[] arrayOfString = new String[10];
request.setAttribute("myStringArray", arrayOfString);
%>
<html>
<body>
<A HREF="receivingPage.jsp">Receiving Page</A>
</body>
</html>
------------------
receivingPage.jsp:
<% String[] arrayOfString = (String[])request.getAttribute("myStringArray");
%>
<html>
<body>
<% if (arrayOfString == null) { %>
Null array!
<% } else { %>
Array Size: <%= arrayOfString.length %>
<% } %>
</body>
</html>
But the arrayOfString object returns null in the receiving page. Why is
this? Of course in this example the string array is empty but it should at
least return me a length of 10, correct? I've searched the archive to avail
other than reference to session.putValue() and session.getValue() methods
which is not what i want.
Any help on this would be great. Thank you!
Nathan
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets