• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to hashmap with html:link to transfer data in STRUTS?

 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am developing my web Application using struts.
In one of my page I want to transfer some bulk of data through querystring (by attaching it to URL) to another page.
I am doing it as follows:-
<jsp:useBean id="paramsMap" class="java.util.HashMap" scope="request" />
<c:set target="${paramsMap}" property="partid" value="${featuredItems.partid}" />
<c:set target="${paramsMap}" property="partno" value="${featuredItems.partid}"/>
<c:set target="${paramsMap}" property="weight" value="${featuredItems.unitweight}"/>
<c:set target="${paramsMap}" property="moq" value="${featuredItems.moq}"/>
<c:set target="${paramsMap}" property="price" value="${featuredItems.listprice}"/>
<c:set target="${paramsMap}" property="desc" value="${featuredItems.description}"/> <html:link page="/addtocartpage.do" paramId="fpartid" paramName="paramsMap">Add to Cart</html:link>
Now when user Clicks on "Add to Cart" link on this page he gets transfered to page corresponding to "addtocartpage.do" action.
Now on that page I want to extract individual parameters from my Hashmap received by querystring. Although I am able to view entire hashmap content onto this second page using:-
<%=request.getParameter("fpartid").toString()%> & I am getting output as
{partno=P0000302, moq=1.0, partid=P0000302, price=487.5, desc=LINER, HONEYCHROMED (NEW)}

But I want to retrieve individual parameter values from this hashmap onto my page. How to do that?

Also is it the correct way that I am using for transferring data through hashmap above?
Please help me.
Thanx in advance.
Prash
 
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you are using the hashmap correctly (although I'm not 100% sure).

You should use a form for your addcarttopage action. When values come in a query string, they will get populated in the form automatically before getting to your action.
 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanx for ur reply. but can u please answer my another qoestion :-
"But I want to retrieve individual parameter values from this hashmap onto my page. How to do that?"

thanx.
pras
 
Dom Lassy
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not at all familiar with JSTL, but can't you just do this:
<c:out value="${featuredItems.partid}"/>?

Also, I think your link should look like this:
<html:link page="/addtocartpage.do" name="paramsMap"/>
[ July 06, 2006: Message edited by: Dom Lassy ]
reply
    Bookmark Topic Watch Topic
  • New Topic