• Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet's request.getParameter() returns null even with matching input/name tag  RSS feed

 
John Smithsonian
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey guys so i have this very simple servlet here


For whatever reason even though both the request.getParamater("customerId"); matches the text input with name=\"customerId\" the System.out.println(customer); returns null no matter what is inputted. Most other issues i see with null request paramaters come from using the id tag instead of name. But here i am using name and STILL getting nothing but nulls. Has anyone seen anything like this before? I've been at it for a few hours now and have absolutely no idea why its not being picked up.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this the servlet that the form is submitting to?

The first time this servlet runs, of course the parameter is going to be null as the form hasn't been sent to the browser yet, let alone allowed the user to interact with it.
 
John Smithsonian
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no the servlet that the form is submitting to is a controller that takes the value of the hidden input and determines what servlet should be instantiated. Could I try debugging the request paramaters in that contoller? What would be the best way to see what's in that session?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The servlet that is being submitted to is the one that will receive the parameter value -- not the servlet that creates the form. Why are you trying to obtain the parameter value before the form is even sent to the browser?
 
H Paul
Ranch Hand
Posts: 491
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Mechanical aspect, I learned and still learning:

1. Use a debugger within an IDE (yours) to see what the code does.
2. Use TCP/IP monitor tool to see the HTTP exchanges (request/response) between the client (browser, for example)
and the server (your web app).
If the tool is not within your IDE, just download one.

2. Reasoning and designing: Just follow Bear's valuable question/advice/posts so far.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!