• Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp getParameter() doesn't function  RSS feed

 
Bogdan Bora
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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
 
Deepakkumar Devarajan
Ranch Hand
Posts: 54
Spring
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Hei,

That was a mistake from my part, but it doesn't change anything. It still passes null.
 
mak pandian
Ranch Hand
Posts: 30
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.)
 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
  • 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.
 
Anindya Roy
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • 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 Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm. You can use Firebug to make sure how you request is being processed from browser to server.

 
Sooraj Rajagopalan
Ranch Hand
Posts: 40
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!