This project is all about taking marks secured by a student as input and calculate GPA(Grade Point Average) using Java Servlets and JSP.
The packet describes GPA calculating using Java servlets ad JSP. A server is required to run the servlets. Tomcat web server is used in this project as the system used is Windows(install a web server according to the system specifications). The files used in the project are 'ResultServlet.class', 'Memo. JSP' , 'Marks.html' and 'web.xml'.
"Marks.html" is the HTML form that is used to take user input. Student name, roll number, and marks secured in each subject are entered in the form table provided by 'Marks.html'.
Upon submitting the form, it makes an HTTP post request to the server. "ResultServlet" is the Java class that extends HttpServlet class to handle the HTTP requests made to the server. ResultServlet class receives the data from the form and it calculates the result of the student. The ResultServlet class determines whether the student is "PASS" or "FAIL" according to the marks submitted and also calculates the GPA of the student. doPost() method of the HttpServlet is overridden to handle the post request made to the server. All the required inbuilt servlet classes are to be imported into the ResultServlet class(import javax.servlet.* and import javax.servlet.http.*).
After computing the GPA and result of the student, ResultServlet forwards the request to 'Memo. JSP' (JSP file) to print the memo of the student based on his/her result. The ResultServlet servlet sets various attributes for web applications like GPA, grade points, and marks to print them in the memo using Memo.JSP file. Memo.JSP file receives attributes set by the ResultServlet and it creates a table to display the result of the student. An additional table is displayed to show the grading system. In this way, different student data entries are made and results can be obtained by submitting the marks.
Steps to run the code:
Install a web server(tomcat webserver) and create a new folder under the "web apps" folder and name your project folder.
Create a new folder named "WEB-INF" inside your project folder. Add HTML and JSP files like 'Marks.html' and 'Memo. JSP' next to the WEB-INF inside web apps. Create two subfolders inside WEB-INF and name them as 'classes' and 'bin'.
Add service-api.jar file to the 'bin' folder and ResultServlet class to the 'classes' folder. Add a web.xml file inside WEB-INF which is used to link java servlets to the web app. Provide URL pattern and class to the Resultervlet class in web.xml file.Compile ResultServlet class to produce ResultServlet.class.
Run the server and provide the URL to the 'Marks.html' (Ex: "http://localhost:8080/project_name/Marks.html")
Enter student name, roll number, and marks secured in each subject and click submit to see the result of the student. The output prints a memo for the student displaying the GPA of the student.
Submitted by Kethireddy Chandra Karan Reddy (ChandraKaran)
Download packets of source code on Coders Packet