Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Send parameters that are being set in a javascript from one jsp to another jsp  RSS feed

 
Sach Nayak
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im quite new to JSP and javascript. Im calculating distance between two places using javascript and storing the distance in a textbox. `document.getElementById('dist').value = drivingDistanceKilometers;`

However when i try to retrieve the value using `String dist = request.getParameter("dist");` I get no value.

Also i tried using `document.location.href = "bookings.jsp?dist="+drivingDistanceKilometers;`
This works for the first time but when I try again it gives no value.

How do I solve this problem?

Sharing more code:

This is inside book.jsp



Inside bookings.jsp:

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds as if you are confusing the name and the ID attributes. The name attribute is what sets the name of the request parameter. ID is not used during form submission.

Also, you should not be putting Java code in a JSP. That is a bad practice that has been obsolete and outdated for over 12 years.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!