Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is it correct

 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isn't there any other way to do the same thing i had to do this becase i'm passing from1 to some constructor which accept simple string. not String[]

String from[] = request.getParameterValues("from");
String to[] = request.getParameterValues("to");
String sub[] = request.getParameterValues("sub");
String message[] = request.getParameterValues("message");

String from1,to1,sub1,message1;

from1 = from[0];
to1 = to[0];
sub1 = sub[0];
message1 = message[0];
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you double handling?


The array shouldn't be required at all.
 
Jigar Naik
Ranch Hand
Posts: 762
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String from[] = request.getParameterValues(from);

if i write this than it wont get compled.
Its giving err : A method getParameterValue(String) in the type servlet request is not applicable for the arguement String[]
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, use getParameter(), and not getParameterValues(). The second one is only used when you expect the parameter to have multiple values, and obviously you do not.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic