Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reloading form page when there's error

 
Parka Teoh
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a login.htm where people can login with their username and password.
I have a servlet to process the info from the page.

How do I print something like "Your username is not filled" on top of the username textfield when the username textfield is empty? (on to the same login.htm)

Do I modify the servlet to print the login.htm? That would seem too manual esp when I have a explicit layout.

Hmmm. I can't get the programming logic...

(I'm using Tomcat 5, winXP)
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use javascript function instead.
something like,

 
Parka Teoh
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's Javascript doing the validation.

So is it possible for the servlet to do the validation?
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah why not. but you request the servlet and get the response from it then show the message to user. and what you are showing is,

"please enter the user name"

which user knows already.

isn't it time taking. this should be on the client end, so the user gets the mistake quickly. anyways.

 
Richard Bradford
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by adeel ansari:
yeah why not. but you request the servlet and get the response from it then show the message to user. and what you are showing is,

"please enter the user name"

which user knows already.

isn't it time taking. this should be on the client end, so the user gets the mistake quickly.

You shouldn't rely on javascript validation though as javascript can be turned off or source code can be edited to remove it.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah you are right but those kind of messages should be from javascript first. thats what i was trying to say.

otherwise you can just say invalid username or password. afterall you are authenticating the user on server side isn't it.

if somebody disable javascript and you are not checking your username field on the server side even then you are authenticating the user right.

but let me say with you "NEVER RELY ON SCRIPT ONLY"
[ September 13, 2004: Message edited by: adeel ansari ]
 
Ajith Anand
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could do something like this :

In the Controller servlet you could set request attributes to flag the validity of the username and password. You could use these variables to show appropriate messages....



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic