aspose file tools*
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
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: 61662
    
  67

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