index.html
<html>
<head>
<title>Marks Entry</title>
</head>
<body>
<h2>Enter Your Marks</h2>
<form action="Insert.jsp" method="post">
Name : <input type="text" name="n1"><br><br>
SPM : <input type="text" name="s1"><br><br>
Asp.Net : <input type="text" name="s2"><br><br>
Advanced Java : <input type="text" name="s3"><br><br>
AI : <input type="text" name="s4"><br><br>
IoT : <input type="text" name="s5"><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
nsert.jsp
<%@page import="mybeans.MarksEntryBean"%>
<%@page import="javax.ejb.EJB"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>Inserted </title>
</head>
<body>
<%
String n=request.getParameter("n1");
int m1=Integer.parseInt(request.getParameter("s1"));
int m2=Integer.parseInt(request.getParameter("s2"));
int m3=Integer.parseInt(request.getParameter("s3"));
int m4=Integer.parseInt(request.getParameter("s4"));
int m5=Integer.parseInt(request.getParameter("s5"));
MarksEntryBean marks=new MarksEntryBean();
String result=marks.Insertdata(n,m1,m2,m3,m4,m5);
out.println("Value Inserted "+result);
%>
</body>
</html>
MarksEntryBean.java
package mybeans;
import javax.ejb.Stateless;
import java.sql.*; @Stateless
public class MarksEntryBean {
public String Insertdata(String n, int m1,int m2, int m3, int m4,int m5)
{ try
{
Class.forName("com.mysql.jdbc.Driver");
Connection
con=DriverManager.getConnection("jdbc:derby://localhost:1527/mysql","root","root");
PreparedStatement ps=con.prepareStatement("insert into student values (?,?,?,?,?,?)");
ps.setString(1, n);
ps.setInt(2, m1);
ps.setInt(3, m2);
ps.setInt(4, m3);
ps.setInt(5, m4);
ps.setInt(6, m5);
ps.executeUpdate();
}
catch(ClassNotFoundException | SQLException e)
{
System.out.println(e);
}
return "Successfully";
0 Comments