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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting an object into the request? 2

Status
Not open for further replies.

gregmosu

Programmer
Joined
Jul 8, 2002
Messages
117
Location
US
How do you set an object into the request? If this were java, I would do something like this...

on one page..
request.setAttribute("myObject",Object); //set Object into the request object.
<jsp:include page=&quot;pg2.jsp&quot; flush=&quot;true&quot; /> //include pg2.jsp(similar to php include)

on second page(pg2.jsp)
Object obj=(Object)request.getAttribute(&quot;myObject&quot;); //get the object back out so I can use it.

I'm yet to find an example of how to set an object into the request and then try to get it back on another page.
 

Will package up the object for you...
Code:
$_SESSION[&quot;my_object&quot;] = serialize(&quot;$object&quot;);

and then on page two...

$object = unserialize($_SESSION[&quot;my_object&quot;]);

I've always used the $_SESSION array to pass between pages, as it's the logical way. If you must use the request stream there are several ways I'm sure. The one that immediately comes to mind is to use cURL. This may be overkill for you though.


I would strongly suggest using sessions. :) cURL is great too though.

-Rob
 
Thanks for the tip Rob, I'll give it a try.

-Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top