Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Dealing with request parameters from callout
Bjorn
This is more of a j2ee question than a FormAPI or FormsPublisher question. But it does pertain...
I'm using a callout to call a servlet, which forwards to a JSP, which can submit back to that servlet, etc. Nothing fancy. Rah rah MVC. Important to note, though, that the reason I have this callout is to complete a process, which may involve said servlet and JSP forwarding back and forth to each other numerous times, depending on what the user needs to do with the servlet/JSP combo.
Anyhow - when I first call the servlet, I'm using (ServletRequest) request.getParameterMap to get the (rather non-uniformly named) parameters from the DCR.. I then attach the resulting map object to the session so that I'll have these parameters available as I keep forwarding between JSP and the sefvlet.
The problem is - of course - that as soon as the parameters are gone, my map object is referencing nothing and I no longer have access to my beloved keys and values. (At least I think that's what's happening)
Any good suggestions that don't involved hidden form fields or URL rewriting?
Find more posts tagged with
Comments
brandon1
Have you tried coying the Map into your own newly created object instead of using the reference to the Map you are given from getParameterMap?
Current Project: Content Services implementation
Bjorn
Yeah. The (good and bad) thing about java is that when you copy an object, it's just referencing the object you want to copy. So even if my copied object exists on the session, it's still referring to something that doesn't exist anymore. Right?
And cloning a Map is a pain and slow.
brandon1
I meant clone when I said copy. I have tried what you are having issues with and am getting the object out, and it is okay.
Current Project: Content Services implementation
Bjorn
Are you sure? Does your example do this:
1 - Callout to servlet
2 - In servlet, getParameterMap and add map object to session
3 - Forward to JSP which looks for map object in session scope - (everything looks ok at this point)
4 - Submit JSP again, servlet forwards back to JSP
5 - Now the map object is gone (empty) from the session
Bjorn
In case anyone cares about this, here's what you have to do to get this to work.
1 - Get the map object that contains the parameters
2 - iterate through the entry set of the map
3 - For each map entry, "clone" the string/array item and put it onto a new hashmap
4 - Attach that new hashmap to the session. Now the map won't conk out when the object to which it refers is gone, because the object to which it refers won't be gone.
Boy -in reading that, it doesn't sound like it makes sense. But it works.