I have couple of JSP pages. The URL for each of the Jsp page shown in browser looks somelike as follows.
What I want ti achieve is as follows:--
In my Jsp page, I should be able to grab above URL and then be able to parse the URL for parameternames and parametervalues and put it in Hashmap (cause i want to send these bunch of parameters to next pages VIA session)
So for example above URL after parsing will give me a Hashmap containing URL parameters as follows :--
p_mycode ------- 2Mon_Fr
mnid ---------- in_ss_ppo_hino_soos Can any one help me here. have done similar thing before ? a>How to grab the URL in the Jsp page ? b>How to parse URL to get name --- value parameters in the Haspmap (number of URL parameters are dynamically changing. Meaning one Jsp page may have 2 parameters other page may have 7 parameters) c>How to pass the haspmap in session ?
Code snippet will help !
When you say "in my JSP page" does that mean you want the JSP code in that page to do something when it's executed? Or did you have in mind the output of the JSP which is in the browser? Or did you want something else to look in the source code of the JSP?
And when you said "grab" a URL, exactly where is that URL coming from? (Follow-up questions to that depend on the answers to the previous questions.)
Edit: my best guess is that the URL in question is the one that requests the JSP. In that case you haven't read any tutorials or other educational material about JSP and you don't understand that you're just asking for the request parameters, which your server has already put into a Map for you. But surely that can't be right.
I want Jsp code to execute in each of the JSP page that will do following :---
a> The Jsp code snippet ( <% .............. %>) will grab the URL appearing in the browser's URL
b> The snippet will then parse the URL to get name --- value parameters from the URL (number of parameter may be 2 or 10. depends)
c>Then same snippet will then prepare some collection (i guess HaspMap) and put all those bunch of parameternames and values in the collection.
d>Then same snippet will PUT that collection in the session ---- ready tobe passed to next page as session object.
Hope this helps.
The way you suggested assumes that you already know the parametersnames (xyz) coming in the URL. and then you would use getParameter("xyz") to get that parameter value. thats easy.
My problem is more than that. The parametersnames we would be getting in our URLs are UNKNOWN. they keep changing. they are not known in advance. so i do not know.
so only way left for me is to get the whole URL string and then parse it using the delimiters ( & ) and then tokenizer.
Has any one done this kind ?