• 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

Problem with Params

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have one JSP that has some fields, the action method is GET and the action is itself.

Problem I am getting is,

every time I submit the JSP, the params are adding to URL. it is good. But in my case the params are appeded each time not overwriting the existing params. Here is example.

http://localhost/App/index.jsp?name=prasad -- First time
http://localhost/App/index.jsp?name=prasad&name=babu -- second time

its not supposed to be like that as i am getting only single param value.

Any idea?

Thanks in advance.
Prasad
 
Prasad Babu
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ben,

Thaks for your reply. I know about what you have mentioned. I want one one parameter value not all. how do we find out the latest one? Here i want to make a note that I want only latest one.

thanks,
Prasad.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have more than one parameter with the same name the best way to retrieve them is to use getParameterValues. If you want a particular one, iterate through the array and grab the one you want.

If you only want one, why are you sending multiple params with the same name?

Also, the servlet spec specifically warns that there is no guarantee as far as the order of params returned. The last one may not necessarily be the one you want.
 
reply
    Bookmark Topic Watch Topic
  • New Topic