This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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


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
Sheriff

Joined: Oct 14, 2005
Posts: 19719
    
  10

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: 63196
    
  69

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

Log4J


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
 
subject: input box for variable x is null in jsp but in servlet the method x.length() returns 10
 
It's not a secret anymore!