struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Riyad Kalla <>
Subject Re: name="params" in <html:submit>?
Date Tue, 27 Apr 2004 02:22:55 GMT
Ahh ok I got you know, comments below:

Julia Weaver wrote:

>Thank you Riyad,
>Yes I want to do:
>>If you are asking how you can (a) create that
>>HashMap in a sciplet in a JSP 
>>page AND put it into the session THEN (b) submit to
>>an Action and get it back 
>>out of the session,
>In My jsp:
>java.util.HashMap params2 = new java.util.HashMap();
>params2.put("p1", "1");	
>params2.put("p2", "2");	
>In my action class:
>String params2 =
This is the problem, in your JSP page you are putting a HashMap into 
your session, then in your action you get getting the HashMap out, and 
casting it to a String. Keep in mind there is NOTHING fancy about a 
Session, its just a Hashtable. So if you put a HashMap in, from your JSP 
page, then the only way you will get it out, is if you cast it 
correctly. Your action code should look like:
HashMap params2 = (HashMap)request.getSession(true).getAttribute("params2");
System.out.println(params2.get("p1"); //output "1"
System.out.println(params2.get("p2"); // output "2"

Anytime you get confused about sessions or requests and the 
get/setAttribute methods... remember they are just wrappers to 
Hashtables and it all becomes clear again.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message