Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add a Map to a HttpServletRequest and then forward using POST

Status
Not open for further replies.

zooxmusic

Programmer
Nov 24, 2004
96
US
Hi all,
I have a question. I may be having this problem because of a design issue but I am here nonetheless.

I need to write a unit test to use with JMeter for my servlet.

My servlet accepts a Map of values right on the InputStream through a POST method (so they are not parameterized and can't use request.getParameter())

I need to write an HTTPRequestSampel for JMeter.

I figure I would write a simple TestServlet that would accept a doGet and then build the Map in there and then POST it (forward preferably) to the real servlet.

Can I use RequestDispatcher.forward(request, resposne) and add this Map to the request object and make the method a POST or am I missing something basic here?

thanks in advance
Brian


Spend like you don't need the money,
love like you've never been hurt and dance like nobody's watching!
 
Hi,

Yes you can use
request.setAttribute("map",new HashMap());
RequestDispatcher("destpage.jsp").forward(request, response);
and can asscess the map in destpage.jsp


Cheers
Venu
 
thanks venur,

wouldn't that make a name value pair of map=(an actual Map)

and then I get it like

request.getParameter("map");
or request.getAttribute("map")

??

because if it is, I can't do that. I need to do something like this; (and its a servlet not a jsp in case that matters)

InputStream in = request.getInputStream();
Map map = (Map)new ObjectInputStream(in).readObject();

Brian


Spend like you don't need the money,
love like you've never been hurt and dance like nobody's watching!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top