Wow – two techie posts in one day! Sorry, non-techie family & friends!
At work, I needed a way to get Javascript array data in and out of my Tomcat Sessions. Given the fragmented state of web development, I was not really too surprised to discover that this extremely common problem does not yet have a simple/common solution.
After a bit of searching, I found this library, which looks pretty cool, but it was way more than I needed. I don’t need full blown RPC, I just need to pass data in and out of my Java Sessions.
So I ended up rolling my own solution: a Struts action (which could just as easily be a Servlet) that takes key/value data from the request and writes it into a named Collection in the Session (if a PUT/POST request method is used), or returns said Collection as a JSONArray. It deletes values as well if you pass “action=delete” in the request params. Returns a 404 if you ask for a Collection it doesn’t know about. Very seemple, very eeessy. If you’re interested in the source, shoot me an email – my boss probably won’t mind!
Chinese herbs will however do both – give you better viagra prescription australia erections and more craving. Larger viagra prescription free ronaldgreenwaldmd.com penis sizes are considered more satisfactory in bed. The herbal energy pill Vital M-40 capsule online levitra ronaldgreenwaldmd.com improves the response of the drugs begins inside 20-30 minutes of utilization. Once they are a few weeks into their regimens, they will have a much super active tadalafil better idea of how the medication treats impotence. It wouldn’t surprise me if hundreds of developers have written essentially the same thing.
What about you PHP guys – is there something even slicker in PHP for doing this?
Incidentally, I finally, totally grokked the true raison d’etre for JSON today: it’s the easiest way to pass simple data structures from a Javascript context to and from a server-side environment. Because JSON *is* Javascript, you can just eval() a JSON string to create a Javascript Array. Pretty nifty!
In PHP I think you’d just away with
$_SESSION = array_merge($_SESSION,$_POST);
This would allow someone to overwrite stuff that perhaps they shouldn’t, so you might want to segment that as follows:
$_SESSION[‘collection’] = array_merge($_SESSION[‘collection’], $_POST);
Pingback: Michael’s Blog » Blog Archive » Accessing Struts message resources from Javascript