• 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

jsp getParameter() doesn't function

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

I have the following code:

<% String callImp = null;

callImp = request.getParameter("callImp");

System.out.println("Call Importer: " + callImp);

if (callImp == null){
System.out.println("Aici null");
%>

and i have an url : /something/welcome.do?callImp="aa"

Why is getParameter always returning null?

Thanks guys
 
Ranch Hand
Posts: 54
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your query string does not need double quotes. Please Remove that and try again , Also please make sure that you are using correct query parameter. This should make it working.
 
Bogdan Bora
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hei,

That was a mistake from my part, but it doesn't change anything. It still passes null.
 
Ranch Hand
Posts: 30
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you please post what error/result you got on your browser? It would be helpful to figure out the issue exactly.
 
Bogdan Bora
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,


There is no error.

String callImp = request.getParameter("callImp") returns null no matter what. No error, just the effect.

Thanks
 
Sheriff
Posts: 67747
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
Why is there Java code in your JSP? That's a bad practice from over 12 years ago. You should be using the JSTL. (In fact, code to deal with form submissions should be in a controller, not a JSP in the first place.)

That said, have you verified that the value in the request is actually there? (Use browser tools to see the requests and responses.)
 
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Please, post the whole jsp page where the above code is found. As it is, i wonder if it would compile.
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post the whole code for this jsp page along with the input <form/>
 
mak pandian
Ranch Hand
Posts: 30
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm. You can use Firebug to make sure how you request is being processed from browser to server.

 
Ranch Hand
Posts: 40
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are getting a value from the servlet into your jsp page.. Any informaion from the servlet to the jsp should be RESPONSE. not REQUEST. In servlet change it to response.setParameter("callImp", callImp);
and in jsp response.getParameter("callImp");
try that..
The reson why callImp returns null is because you have already set it to null and the next line which is "supposed" to change has nothing to enter because when a value is sent from the servlet to the jst, its a response. and when the values that go from the jsp to servlet (like input="submit") can received at the servlet using request.
and like mention above, this is a bad practice. For the sake of learning, is ok.. but use taglibs.
 
Hey! You're stepping on my hand! Help me tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic