Hi i am making a new user page where user will fill username and password and i want to put some client side validation on it

Suppose user has given wrong values in password and Confirm password column so before a request is send to secnd servlet i want to restrict user with a validation message

I dont want to use Java script i wan to write some code in my Servlet1 only

Can you please tell me if it is possible

Where does a servlet run? On the client or on the server. Once you answer that question you will know whether or not you can perform client side validation in a servlet.

Also, your application should never rely on any kind of operations on the client side. They may have the needed resources disabled, or they may be spoofing the results, whatever, you don't know. It should always, always, be checked again on the server side. You can have client side validation, but it should only be used for convenience (i.e. giving the user the opportunity to correct an entry before it is sent to the server), and should never be relied upon by the server.