Validating username and password in servlet

"select * from mgsch.register where user_name='" u "' and pass_word='" p "' " mgsch.register is the table where the i insert the values from the registration page.

Joseph, The error is telling you it cannot compile the jsp.

Then compare with the password that you got from html page and the password from the query If the above is not working out, I recommend you to keep the presentation(view) in JSP, validation in a servlet.

Also keep the dbase connections in a separate class.

a) Http Servlet Request interface Following is the hierarchy.

The first parameter can be either of Servlet Request or its sub-interface Http Servlet Request.

We use Servlet Request as parameter when we extend Generic Servlet and Http Servlet Request when Http Servlet is extended.

The other way is get Parameter Names() where all the data is extracted in a single stretch in a for loop. out.close(); When the job is over, it is customary to close the streams as you have done in file copying.Server receives, validates and sends back the validation result to client as response. Following is the Servlet version for the above JSP file. See the length of coding between a Servlet and JSP doing the same job.Following is the client-side HTML file calling File Name: User is known as Scriptlet. HTML screen when User name and Password are entered. Enter user name and password and click submit button. That is, req object of Http Servlet Request receives data sent by client.From this object, the servlet programmer can extract the data and can use for validation or other purposes as hereunder. out.println("VALID"); We know earlier the Http Servlet Response is meant to send data (known as response) to client. As a convenience, the get Writer() method of Servlet Response (inherited by Http Servlet Response) returns an object of Print Writer.

Leave a Reply