Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

urgent!! request.getParameter()

 
Dolly Patel
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i have a form with 60+ paramters. I dont want to manually do request.getParameter(param) on each one of them....is there any other way to handle this....Please help
Thanks
[ May 07, 2003: Message edited by: Dolly Patel ]
 
R K Singh
Ranch Hand
Posts: 5384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use struts framework and eclipse[to genrate get/set methods]
else you can use req.getParameterNames() or getParameterMap() .. but still I think you have to write those 60+ html elements at some point of time.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65115
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adopting a framework just to auto-generate a handful of statements seems a bit extreme.
It might be helpful if you'd let on just what is you need to do with the 60+ parameter values.
hth,
bear
 
Chris Baron
Ranch Hand
Posts: 1061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dolly,
Here are 2 ways from my code-snippet-collection to simplify checking parameters for null:

hth cb
 
Weerawit Maneepongsawat
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think should used like this..
<jsp:setProperty name="entry" property="*" />
fix me..
 
DC Dalton
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is one other way that I use a LOT when handling big requests likle this. Use:
req.getParamterNames() which returns an Enumeration of the incoming names along with a Hashtable to grab the incoming values like this:
Enumeration enum = req.getParameterNames();
Hashtable myInfo = new Hashtable();
while (enum.hasMoreElements()) {
String name = enum.nextElement();
myInfo.put(name, req.getParameter(name));
}
This is great when you have a ton of paramaters coming in & dont want to go thru the manual grabbing of every last one (OH what a pain)
Once you have everything in the Hashtable you can test & run thur them in a loop & away you go!....hope this helped.
[ May 08, 2003: Message edited by: DC Dalton ]
 
Rohit Ahuja
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Common Dolly,
Do'nt be so lazy, especially when u have tools like textpad and keys like ctrl,C and V.
 
Rohit Ahuja
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i was just wondering whether ur field names are more or less the same.
If they r X1,X2... then u could loop them thru a for loop and pass it to request.getparameter();
for( int i = 0; i < 60 ; i++ )
{
S.O.P( request.getparameter("X"+i) );
}
This is just the skeleton,does it help??
 
Kaustubh Patil
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dolly,
May be using a javabean for the display is a good idea to populate all the form fields.
-Kaustubh.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic