It's not a secret anymore!*
The moose likes JSP and the fly likes request.getParameter return null value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "request.getParameter return null value" Watch "request.getParameter return null value" New topic
Author

request.getParameter return null value

Sagar Dumbre
Greenhorn

Joined: Mar 02, 2012
Posts: 12
AJAX has retrieved value(using some DB operation)and inserted in text box.while retrieving that values on onClick event of button System.out.println shows null value.i want to retrieve value of "emp" input tag
jsp file code:-

Ajax JSP Code:-
---------------------
For my testing purpose when i write
on submit button click event i get null value in console but values is get displayed in JSP main page.
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 507

Try this


request.getParameter returns the value not the innerHTML..


Regards, Prasad
SCJP 5 (93%)
Nam Ha Minh
Ranch Hand

Joined: Oct 31, 2011
Posts: 498

The div tag and the input tag have same id: emp
Make them different.


PM Me If You Want to get Urgent Help on Java Programming
Sagar Dumbre
Greenhorn

Joined: Mar 02, 2012
Posts: 12
Prasad Krishnegowda wrote:Try this


request.getParameter returns the value not the innerHTML..


I have provided you whole file code...just go through it..

"ddlFlat" which is also ajax processing... that value retrieving properly in page and in also request.getparameter but the emp value is retrieving properly in page but null when try to get request.getparameter value
Sagar Dumbre
Greenhorn

Joined: Mar 02, 2012
Posts: 12
Nam Ha Minh wrote:The div tag and the input tag have same id: emp
Make them different.


I've removed ID attribute of input tag..but no use :(
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 507

Remove the id emp from div and put it to the input tag with name emp..

You have got a lot to fix in the code, first thing is no Java inside JSP, its been discredited for 10 years now.
Next, JSP's should be used only as a view, all other processing should be done in the servlets..
Sagar Dumbre
Greenhorn

Joined: Mar 02, 2012
Posts: 12
Prasad Krishnegowda wrote:Remove the id emp from div and put it to the input tag with name emp..

You have got a lot to fix in the code, first thing is no Java inside JSP, its been discredited for 10 years now.
Next, JSP's should be used only as a view, all other processing should be done in the servlets..


I have used "getElementByID" method to retrieve the value from Ajax processing page so how can that be done ?
and "document.getElementById("emp").value=xmlHttp1.responseText" when i use this value not printed on jsp page so switched to innerHTML one.
And i know you are talking about MVC but my org. forced me to do whole processing in one JSP page so cant help it.
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 507

Sagar Dumbre wrote:i know you are talking about MVC but my org. forced me to do whole processing in one JSP page so cant help it.

If can't believe why the organization(I believe you refer your manager/lead as organization?) don't wan't to get into good practices...
If what you said is correct, then it might well be a good option, to spend some time on Naukri or Monster..

EDIT: i just saw your code, you are returning the whole input tag element only as the AJAX response..
Define the input tags in JSP and just return the values as AJAX response, and use the getElementById('').value to set the AJAX responses to the appropriate fields..
ashwin venkat
Greenhorn

Joined: Mar 03, 2012
Posts: 8
[thread hijack removed. Please ask your own questions in your own topics.]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: request.getParameter return null value
 
Similar Threads
Is it possible to call a servlet function using JavaScript?
using ajax and struts iterate tags
Getting error
How to getParameter value
Doubts in jsp