aspose file tools*
The moose likes JSP and the fly likes Problem with Params Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Problem with Params" Watch "Problem with Params" New topic
Author

Problem with Params

Prasad Babu
Ranch Hand

Joined: Jul 17, 2005
Posts: 57
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
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

See:
java.lang.String)" target="_blank" rel="nofollow">http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequest.html#getParameterValues(java.lang.String)


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Prasad Babu
Ranch Hand

Joined: Jul 17, 2005
Posts: 57
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

Joined: Dec 11, 2004
Posts: 13410

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with Params