Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

EXPERIMENT – 14

 Name = Pratiksha B. Bhawar.


 Roll No = 176171.
 Batch = IF-3

1) Simple JSP Program –

 HTML Program –
<html>

<form action="http://localhost:8081/NewYear.jsp" method="post">

<br><br>

<input type="submit" value="Click"/>

<br><br>

</form>

</html>

 JSP Program –
<html>

<head>

<title> First JSP Page </title>

</head>

<body>

<p align="center"> <font color="#FF0000" size="6">

<%= "WELCOME" %>

</font>

</p>
<p align="center">

<%= "HAPPY NEW YEAR" %>

</p>

</body>

</html>

 OUTPUT –

2) DATABASE PROGRAM –
 Html code –

<html>

<body>

<form action="http://localhost:8084/show.jsp" method="post">

<b>ID:</b></br >

<input type="text" name="id" /></br >

<b>Name:</b></br >
<input type="text" name="name" /></br >

<b>college Name:</b></br >

<input type="text" name="coll_name" /></br >

<b>Percentage:</b></br >

<input type="text" name="percentage" /></br >

</br >

<input type="submit" value="GO" />

</form>

</body>

</html>

 JSP code –
<%@ page import="java.sql.*" %>

<%@ page import="java.io.*" %>

<%@ page import="java.lang.*" %>

<%

response.setContentType("text/html");

try

Class.forName("oracle.jdbc.driver.OracleDriver");

Connection con=DriverManager.getConnection(

"jdbc:oracle:thin:@localhost:1521:xe","system","root@123");

Statement stmt=con.createStatement();
int i=stmt.executeUpdate("insert into students
values("+request.getParameter("id")+",'"+request.getParameter("name")+"','"+request.get
Parameter("coll_name")+"',"+request.getParameter("percentage")+")");

ResultSet rs=stmt.executeQuery("select * from students");

out.println("<html><table border=0>");

out.println("<tr><th>ID</th><th>Name</th><th>COllege
Name</th><th>Percentage</th></tr>");

while(rs.next())

out.println("<tr><td>"+rs.getInt(1)+"</td><td>"+rs.getString(2)+"</td><td>"+rs.g
etString(3)+"</td><td>"+rs.getInt(4)+"</td></tr>");

out.println("</table></html>");

rs.close();

con.close();

stmt.close();

catch(Exception e)

out.println(e);

%>

 Output –

You might also like