• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

request.getParameter() returns a null value in the servlet

 
Greenhorn
Posts: 23
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nandhakumar Soundarrajan wrote:





your url-pattern is <url-pattern>/newproject</url-pattern> in web.xml
 
Nandhakumar Soundarrajan
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


HTML tag atrributes should be in double quotes.

Try changing to



Hope it will solve your problem.
 
Nandhakumar Soundarrajan
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not getting any exception in my console and browser is blank..
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

can you try printing the parameter names from the request?



 
Nandhakumar Soundarrajan
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Srini,

request.getParameterNames() also returned null value...
 
Ranch Hand
Posts: 72
Scala Monad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
request.getParameterNames() never returns null. In case 'request' has no parameters, the method returns an empty Enumeration.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Marimuthu,

The getParameterNames returned empty enumerator java.util.Hashtable$EmptyEnumerator@1b044df
 
Nandhakumar Soundarrajan
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

I just found that my doGet is working, but I do not know, why doPost is not working...
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nandhakumar Soundarrajan wrote:I just found that my doGet is working, but I do not know, why doPost is not working...


 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post your Servlet Code . earlier you post only doPost() . it might be help to figure out the problem
 
Mohamed Inayath
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSP and web.xml will be useful as well.
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic