| Author |
request.getParameter() returns a null value in the servlet
|
Nandhakumar Soundarrajan
Greenhorn
Joined: Apr 24, 2009
Posts: 23
|
|
Hi guys,
I am struggling with a basic stuff and I could not succeed, I have developed many web apps but never faced a similar problem, please help me out...
My servlet is returning null value for request.getParameter("pname");
JSP Code:
web.xml
Servlet Code
-Nandhakumar S.
|
Thanking the green horns sincerely,
Nandha
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56224
|
|
Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.
You can go back and change your post to add code tags by clicking the button on your post.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56224
|
|
Nandhakumar Soundarrajan wrote:Expecting your response...
"Expecting"? Don't you think that's a tad rude? You might want to re-evaluate your approach.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56224
|
|
|
It's not at all clear how the servlet is invoked and what relationship it has to the JSP as the action of your form submits to another JSP, not the servlet.
|
 |
Nandhakumar Soundarrajan
Greenhorn
Joined: Apr 24, 2009
Posts: 23
|
|
I am sorry, I am new to this forum...
Actually the form submit will be calling
I was trying several things, but even a JSP could not get the parameter from the request
Sorry that's my mistake, please help me out
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
Nandhakumar Soundarrajan wrote:
your url-pattern is <url-pattern>/newproject</url-pattern> in web.xml
|
 |
Nandhakumar Soundarrajan
Greenhorn
Joined: Apr 24, 2009
Posts: 23
|
|
Hi Seetharaman,
I have tried that but not working... for the past two days I am struggling with this, I don't no what went wrong.. other webapps in the same server works fine.
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
Well first make sure that the capitalization is correct. I think request parameters are case sensitive so Pname and pname are different. Although your code shows correct capitalization, still it would be a good idea to recheck it.
Also I'm not sure of the input tag syntax you are using. Try using this
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
Mohamed Inayath
Ranch Hand
Joined: Nov 22, 2004
Posts: 124
|
|
HTML tag atrributes should be in double quotes.
Try changing to
Hope it will solve your problem.
|
 |
Nandhakumar Soundarrajan
Greenhorn
Joined: Apr 24, 2009
Posts: 23
|
|
It didn't workout
Also, I tried submitting the form to a JSP file and in the JSP also, I am unable to get the parameter...
|
 |
Mohamed Inayath
Ranch Hand
Joined: Nov 22, 2004
Posts: 124
|
|
Hey.
Are you sure the request in getting posted to your servlet.
Secondly, have you changed the attributes to double quotes..
Its not only input tag but all the tag attributes available in your form/html.
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
Mohamed Inayath wrote:
HTML tag atrributes should be in double quotes.
For information : it is not must
Coming to the problem . did you get any exception ? what you see in your browser response?
|
 |
Nandhakumar Soundarrajan
Greenhorn
Joined: Apr 24, 2009
Posts: 23
|
|
|
I am not getting any exception in my console and browser is blank..
|
 |
srinivasa varadhan
Greenhorn
Joined: Oct 03, 2003
Posts: 19
|
|
Hi,
can you try printing the parameter names from the request?
|
Srini...
Torch your Thoughts....
|
 |
Nandhakumar Soundarrajan
Greenhorn
Joined: Apr 24, 2009
Posts: 23
|
|
Hi Srini,
request.getParameterNames() also returned null value...
|
 |
Marimuthu Madasamy
Ranch Hand
Joined: Jun 07, 2007
Posts: 72
|
|
|
request.getParameterNames() never returns null. In case 'request' has no parameters, the method returns an empty Enumeration.
|
- Marimuthu Madasamy
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56224
|
|
Mohamed Inayath wrote:Secondly, have you changed the attributes to double quotes.
Eitehr double or single quotes can be used, though it more customary to use double quotes.
|
 |
Nandhakumar Soundarrajan
Greenhorn
Joined: Apr 24, 2009
Posts: 23
|
|
Hi Marimuthu,
The getParameterNames returned empty enumerator java.util.Hashtable$EmptyEnumerator@1b044df
|
 |
Nandhakumar Soundarrajan
Greenhorn
Joined: Apr 24, 2009
Posts: 23
|
|
Hi Guys,
I just found that my doGet is working, but I do not know, why doPost is not working...
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
Nandhakumar Soundarrajan wrote:I just found that my doGet is working, but I do not know, why doPost is not working...
|
 |
jack wenttohill
Greenhorn
Joined: Apr 26, 2009
Posts: 9
|
|
I know you get it using doGet, but still my curiosity is the URL patern in form action tag, it shouldn't contains a slash /
The code above will work fine for doPost(..)
Thanks
Jack
|
 |
Nandhakumar Soundarrajan
Greenhorn
Joined: Apr 24, 2009
Posts: 23
|
|
Hi,
Please help me out in finding why my doPost is not working...
Sorry to bother you all, its a bit urgent..
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
|
Please post your Servlet Code . earlier you post only doPost() . it might be help to figure out the problem
|
 |
Mohamed Inayath
Ranch Hand
Joined: Nov 22, 2004
Posts: 124
|
|
JSP and web.xml will be useful as well.
|
 |
kan nat
Greenhorn
Joined: Mar 19, 2009
Posts: 28
|
|
there is no issue in your jsp/servlet, i tried its working , since you are using system.out.println, the servlet prints the form values in standard output, not the browser. if you want it to print in browser , use printwriter instead. let me know if you able to.
|
 |
 |
|
|
subject: request.getParameter() returns a null value in the servlet
|
|
|