Javatpoint Logo
Javatpoint Logo

Example of Fetching Result for the given rollno

Here, you will learn that how to fetch result for the given rollno. I am assuming that there is a table as given below:

We are assuming there are many records in this table. In this example, we are getting the data from the database in servlet and printing it. We are doing all the database logic in servlet for simplicity of the program. But it will be better to separate it from the servlet file.

Example of Fetching Result for the given rollno

In this example, we have create three files

  • index.html
  • web.xml


This page gets rollno from the user and forwards this data to servlet which is responsible to show the records based on the given rollno.

This is the servlet file which gets the input from the user and maps this data with the database and prints the record for the matched data. In this page, we are displaying the column name of the database along with data, so we are using ResultSetMetaData interface.

web.xml file

This is the configuration file which provides information of the servlet to the container.

To connect java application with the Oracle database ojdbc14.jar file is required to be loaded. Put this jar file in WEB-INF/lib folder.

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA