Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

request.getParameter() and JavaScript

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my jsp page, I'm setting the value of a hidden textbox and I'm trying to retrieve the contents of that text box in a Servlet using request.getParamter, but I'm getting "null" as a result. First I set the value of the hidden paramter in javascript. I don't use an "action" for my form. Instead I use location.href in javascript. Can someone PLEASE help?
Here is the JSP page:
<Javascript>
function setValue(str1, str2)
{
document.test.name.value = str2
document.test.submit();
location.href = "/myPage/" + str1;
}
</javascript >
<form name="test"><input type=hidden name="name" value="">
</form >
<a on_click = "setValue('Hello', 'World');" Click me!</a >
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well Jolly, I'm not sure how the Request.getParameter() fits into all this since you mention it in your message, but do not reference it anywhere in your example code. But, I think the javascript you want is more along the lines of:

This probably should be moved to the Javascript forum.
hth,
bear
 
Jolly Khanna
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Bear,
Thanks for your help.
The request.getParameter() was being used to set the value of "name" to an object. In my Servlet I was calling String name = request.getParameter("name"); but the value was coming up null.
 
reply
    Bookmark Topic Watch Topic
  • New Topic