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.
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
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:
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.
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.