Submit comments in database when user clicks on submit button
This is detailed java code to show how to submit comments from a jsp page and insert it to the MySql database when user clicks the submit button of the page.
Create a database: First create a database named "usermaster" in MySql and table named "user_master" in same database by SQL query given below:
Now create the JSP page for the user to place the comment and submit the comment. For this we have created first_page.jsp as below.
Save this code as a .jsp file named "first_page.jsp" in your application directory in tomcat server and run this jsp page with url "http://localhost:8080/user/first_page.jsp" in address bar of the browser.
Now create another JSP "ConnectJspToMysql.jsp" which retrieves the comment written by the user in the previous page and insert it to the database. To connect with the database you need database driver jar file in the lib directory of your application directory in Tomcat.
Save this code as a .jsp file named "ConnectJspToMysql.jsp" in your application directory in Tomcat.
To start Tomcat server run startup.bat file from directory Tomcat-6.0.16/bin/startup.bat. To run this application open browser and type http://localhost:8080/user/first_page.jsp in address bar and open this jsp page.
Fill all the fields in the form, student id must be integer number then click submit button. If all the values are submitted successfully in database, this page will call another jsp page that shows following message on the page..
If found any error to submit data in database shows following error message....