Originally Posted by
game06
Question 1: is this the proper way of using jsp/servlet?
Question 2: when user hit submit button in html form than it will run java code. but in servlet.java class the error will never print on login.jsp.
First, Servlets it's better if they are in a package, not in the "default" package.
Second, you must map, into the web.xml, the url
/servlet (or whatever url you would like to specify in the action attribute) to your servlet. It's not automatic. Putting
action="servlet" doesn't mean, automatically, that a servlet named "servlet" is invoked!
Third, in the "good" use of JSP/Servlet, a Servlet should not do output directly to the response. At most it should do a redirect or a forward to another internal resource (e.g. a JSP, tipically).
Fourth (not less important), since the form is submitted in POST, your servlet must handle this request in the doPost, not doGet.