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 Servlets and the fly likes request.getParameter() and JavaScript 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 » Servlets
Bookmark "request.getParameter() and JavaScript" Watch "request.getParameter() and JavaScript" New topic
Author

request.getParameter() and JavaScript

Jolly Khanna
Greenhorn

Joined: Sep 24, 2001
Posts: 12
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 >
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60738
    
  65

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jolly Khanna
Greenhorn

Joined: Sep 24, 2001
Posts: 12
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: request.getParameter() and JavaScript
 
Similar Threads
Java array and javascript array
to get boolean value in jsp
printing values
Form input type=hidden - is it possible to set values dynamically
display value in Struts jsp page