By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,874 Members | 1,028 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,874 IT Pros & Developers. It's quick & easy.

How to retrieve a parameter?

P: n/a
I have the following function in a html file:

function selectEdit(fileID, processCode, processID, fileName,fileDesc)
{
document.forms[0].recordID.value = fileID;
document.forms[0].processor.value = processCode; `
document.forms[0].processorID.value = processID;
document.forms[0].interfaceFileName.value = fileName;
document.forms[0].fileNameDesc.value=fileDesc;
document.forms[0].submit();
}
The function is called by many buttons in the same form.
Each button is supposed to be redirecting to different html pages
based on the parameter "document.forms[0].recordID.value" i have
directed the form action to a jsp page to handle the redirection but i
cannot get the parameter using jsp. Can i retrieve the
"document.forms[0].recordID.value" if so how?
Do i use javascript to retrieve? I tried using
request.getParameter("recordID")in my jsp but i get a null pointer
exception.
Am i retrieving the value corrrectly?

Thanks
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
In article <59**************************@posting.google.com >, scout3014
@gmail.com enlightened us with...
I have the following function in a html file:

function selectEdit(fileID, processCode, processID, fileName,fileDesc)
{
document.forms[0].recordID.value = fileID;
document.forms[0].processor.value = processCode; `
document.forms[0].processorID.value = processID;
document.forms[0].interfaceFileName.value = fileName;
document.forms[0].fileNameDesc.value=fileDesc;
document.forms[0].submit();
}
The function is called by many buttons in the same form.
Each button is supposed to be redirecting to different html pages
based on the parameter "document.forms[0].recordID.value" i have
directed the form action to a jsp page to handle the redirection but i
cannot get the parameter using jsp. Can i retrieve the
"document.forms[0].recordID.value" if so how?
Do i use javascript to retrieve? I tried using
request.getParameter("recordID")in my jsp but i get a null pointer
exception.
Am i retrieving the value corrrectly?


Javascript runs on the client. It has nothing at all to do with Java, despite
the name of the language.
JSP is Java Server Pages. It IS Java. (java is OT here)

Javascript cannot retrieve posted form values. It can parse a URL for GET
params.
JSP can retrieve either.

request.getParameter will never give you a null pointer exception - it's what
you're doing afterwards that is giving you the exception. If no value exists
for the param, it returns null.
From what I can tell, request.getParameter is getting null for recordID. That
means there is no value. Check what is actually get sent to the server. Just
out.print the values of the form params in the JSP and comment everything
else out. Did you get a value for recordID? If so, it's your JSP code that is
the issue, not your javascript.

Javascript is NOT a typed language - if you call the function wrong, it won't
complain overmuch. Not like Java. Are you SURE you're passing the right info
to the javascript function? Place some alerts in there if you're not sure.
See what you're really passing for fileID (which is then assigned to
recordID).

HTH

--
--
~kaeli~
Synonym: the word you use in place of a word you can't
spell.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.