*
The moose likes Servlets and the fly likes Reloading form page when there's error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Reloading form page when there Watch "Reloading form page when there New topic
Author

Reloading form page when there's error

Parka Teoh
Ranch Hand

Joined: Aug 28, 2004
Posts: 40
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)


Do you have a parka?<br /> <br /><a href="http://sg.geocities.com/inschooool" target="_blank" rel="nofollow">Visit my homepage</a> | <a href="http://parka.deviantart.com/" target="_blank" rel="nofollow">Parka Deviantart gallery</a>
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
use javascript function instead.
something like,

Parka Teoh
Ranch Hand

Joined: Aug 28, 2004
Posts: 40
That's Javascript doing the validation.

So is it possible for the servlet to do the validation?
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
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

Joined: Apr 20, 2004
Posts: 48
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

Joined: Aug 15, 2004
Posts: 2874
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

Joined: Aug 30, 2004
Posts: 40
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....





LXI Technologies P Ltd
[url]www.lxisoft.com[/url]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reloading form page when there's error
 
Similar Threads
websphere 4.0 ..help needed ..pl ..very very urgent..
Session and NullPointerException! URGENT!
calculator problem
Authnetication and getRemoteUser()
Error 500: ClassNotFoundException