Forums Register Login

how to show validation error messages on the jsp login fields from servlet

+Pie Number of slices to send: Send
Hi,

I have login jsp with 3 fields,userid,password and dropdown.When the jsp is submitted,the request goes to a servlet.I want to validate these 3 inputs inside the doPost() method of the servlet.Is it possible to display some error messages on the fields(userid,password,dropdown) of the jsp field if these fields are empty? Also,I want to pass these messages from the doPost() method of the servlet on the fields of the jsp.

Please give some advice as to how can I do this.


Many Thanks in advance!

+Pie Number of slices to send: Send
You can always validate these fields and then return a validation message to the user when you redirect to that page. You can achieve declarative security with form login. Not sure what you need with the drop down, so if your container can be configured to recognize that then form login should do well.

You should be able to achieve this with more ease if you use struts
+Pie Number of slices to send: Send
Hi,

I am working on a simple tomcat based jsp/servlet application.How can I redirect back to the jsp fields if I give null conditions in the doPost() method like:



Is this possible to implement?

Please advice

Thanks

+Pie Number of slices to send: Send
 

Is this possible to implement?



Yes. You can set any messages in request scope etc.. then do a forward to the previous jsp. If you use a redirect you will have to provide those messages in the URL because browser will make a separate request for the redirect.
+Pie Number of slices to send: Send
Thanks for the reply.Please could you provide some sample code if possible? That would be really great!!

Thanks
+Pie Number of slices to send: Send
I resolved this issue by using javascript validation.

Thanks!
+Pie Number of slices to send: Send
 

Moieen Khatri wrote:I resolved this issue by using javascript validation.



Good. but you must learn on server side also
+Pie Number of slices to send: Send
 

Moieen Khatri wrote:I resolved this issue by using javascript validation.

Thanks!



Whether you do it with javascript or not, you must always validate your parameters on the server side.
+Pie Number of slices to send: Send
Thanks Deepak

I use client side validation for checking if the attributes are entered or not and I use server side validation to check if the login is successful or not.

Thanks for the advice!

Cheers
+Pie Number of slices to send: Send
 

Deepak Bala wrote:Whether you do it with javascript or not, you must always validate your parameters on the server side.


Quoted for emphasis.

Never rely on client-side validation. Your server-side code must act is if no client-side validation has taken place. None.
Yeah, but does being a ninja come with a dental plan? And what about this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 6255 times.
Similar Threads
passing input type="text" from jsp to bean & using that in servlet
Focus
Security issue
Not able to navigate the user to another jsp in servlets using RequestDispatcher
Forwarding from doPost to doGet
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 20:09:01.