File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes urgent!! request.getParameter() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "urgent!! request.getParameter()" Watch "urgent!! request.getParameter()" New topic

urgent!! request.getParameter()

Dolly Patel

Joined: Nov 25, 2002
Posts: 4
i have a form with 60+ paramters. I dont want to manually do request.getParameter(param) on each one of there any other way to handle this....Please help
[ May 07, 2003: Message edited by: Dolly Patel ]
R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5382
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.

"Thanks to Indian media who has over the period of time swiped out intellectual taste from mass Indian population." - Chetan Parekh
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63868

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.

[Asking smart questions] [About Bear] [Books by Bear]
Chris Baron
Ranch Hand

Joined: Mar 21, 2003
Posts: 1061
Hi Dolly,
Here are 2 ways from my code-snippet-collection to simplify checking parameters for null:

hth cb
Weerawit Maneepongsawat
Ranch Hand

Joined: Apr 11, 2002
Posts: 203
I think should used like this..
<jsp:setProperty name="entry" property="*" />
fix me..

Weerawit<br />SCJP 1.4, SCWCD 1.2, SCWCD 1.4, SCBCD 1.3, SCBCD 5.0, SCMAD 1.0, SCJA 1.0, SCDJWS, SCJD, SCEA, SCDJWS 1.5
DC Dalton
Ranch Hand

Joined: May 28, 2001
Posts: 287
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

Joined: Oct 04, 2001
Posts: 121
Common Dolly,
Do'nt be so lazy, especially when u have tools like textpad and keys like ctrl,C and V.

Face Off.
Rohit Ahuja
Ranch Hand

Joined: Oct 04, 2001
Posts: 121
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

Joined: Aug 13, 2001
Posts: 164
May be using a javabean for the display is a good idea to populate all the form fields.

Kaustubh. Mumbai, India.
I agree. Here's the link:
subject: urgent!! request.getParameter()
jQuery in Action, 3rd edition