This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Problem with Params" Watch "Problem with Params" New topic

Problem with Params

Prasad Babu
Ranch Hand

Joined: Jul 17, 2005
Posts: 57

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.
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

java.lang.String)" target="_blank" rel="nofollow">

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.

Ben Souther

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:
subject: Problem with Params
Similar Threads
URL - getting appended
Passing Parameters to JSP page from HTML page
Apache Tomcat/4.0.1 - HTTP Status 500 - Internal Server Error
can logic:forward pass a parameter?
problems - displaying a jsp page with jsf tags