jQuery in Action, 2nd edition*
The moose likes Servlets and the fly likes input box for variable x is null in jsp but in servlet the method x.length() returns 10 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "input box for variable x is null in jsp but in servlet the method x.length() returns 10 " Watch "input box for variable x is null in jsp but in servlet the method x.length() returns 10 " New topic
Author

input box for variable x is null in jsp but in servlet the method x.length() returns 10

ashley Jug
Ranch Hand

Joined: Sep 02, 2011
Posts: 60
Hello,

i have the following jsp as my log in page:



The following code is my servlet:



However even when the username and password is null in the log in page the logger for passwrd.length() and name.length() is int 10.
When i run name.trim().length() it returns int 0.

How is it initialising a null input box?
Any suggestion please?

Thanks in advance.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

I don't understand. The HTML you posted there is going to be displayed to the user, and they are going to fill in the fields and press the Submit button, right? And then that's going to submit the fields to the servlet code you posted, right?

And you described the HTML you posted as a JSP. So your JSP generates the HTML and sends it to the browser, where the user will then fill in the fields. So I don't see why you would expect the JSP to contain that data, when the user hasn't even typed it yet.
Prashant Chindhade
Ranch Hand

Joined: Jan 19, 2011
Posts: 77
what this logger.info() does..?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

prashant chindhade wrote:what this logger.info() does..?

Log4J


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
wood burning stoves
 
subject: input box for variable x is null in jsp but in servlet the method x.length() returns 10
 
Similar Threads
How to update a data in database from jsp
how to pass Parameter in custom tag
Data truncation: Truncated incorrect DOUBLE value:
how to keep register page data if register fails
Help needed in login page