Solved

Attaching a map retrieved from request.getParameterMap to the session scope

Posted on 2004-10-04
4
608 Views
Last Modified: 2008-02-01
We use a content management system that allows custom functionality via JSPs/servlets.  When you call a servlet or JSP from the content management system, it's POSTs a bunch of proprietary parameters that you can use in the custom functionality.

I am calling a servlet and using the request.getParameterMap() method to get a map of the keys and values (parameters) POSTed from the content management system.  Then I attach this map to the HttpSession and forward to a JSP.  From that JSP, the user can do some stuff, and then submit the form on the JSP, which goes to the servlet again, which does some more processing and then forwards back to the JSP.

After I submit the JSP the 2nd time, I lose all the keys and values (entries) in my map object in the session.  I think this is because they're just references to something that doesn't exist anymore.

I will write out the steps involved and show you where it fails:
1 - Call servlet from the content management system.  A session already exists.
2 - The servlet uses the getParameterMap method to get a map object and then attaches it the existing session.  Then it forwards to a JSP.
3 - The JSP does stuff.  I can iterate through the map object attached to the session and see all my keys and values.
4 - If I submit the JSP, it goes to the servlet, which has IF logic NOT to add the parametermap to the session.  I only want to do this the first time the servlet is accessed (called by the content management system).  Then it forwards to the JSP again.
5 - Here's where I am stuck.  Now if I try to access keys or values from the map, I can see that there are none.  The map object no longer has any entries.

0
Comment
Question by:b2johnso
4 Comments
 

Expert Comment

by:osource_dev
ID: 12220735
can you send the servlet code and the JSP page ?
0
 

Author Comment

by:b2johnso
ID: 12225940
I ended up just iterating through the map, "cloning" the string objects at the entry level and then adding those to a new map.  This solved the problem of the map referring to something that no longer exists.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12537117
PAQed, with points refunded (400)

modulo
Community Support Moderator
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When we purchase storage, we typically are advertised storage of 500GB, 1TB, 2TB and so on. However, when you actually install it into your computer, your 500GB HDD will actually show up as 465GB. Why? It has to do with the way people and computers…
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question