import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class DisplayServlet extends HttpServlet
{
Connection con;
Statement st;
public void init(ServletConfig sc)
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","system");
System.out.println(con);
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void doGet(HttpServletRequest req,HttpServletResponse res)
{
try
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
st=con.createStatement();
ResultSet rs=st.executeQuery("select * from student");
while(rs.next())
{
out.println("sno is:"+rs.getInt(1)+"\nSname is :"+rs.getString(2)+ "\ncourse is : " +rs.getString(3));
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void destroy()
{
try{ con.close(); }
catch(Exception e)
{
e.printStackTrace();
}
}
}
index.html:-
html
body
form action="./display"
input type="submit" value="Display Student Details"/
/form
/body
/html
web.xml:-
web-app
servlet
servlet-nameex1/servlet-name
servlet-classDisplayServlet/servlet-class
/servlet
servlet-mapping
servlet-nameex1/servlet-name
url-pattern/display/url-pattern
/servlet-mapping
Plz Subscribe to the Channel and if possible plz share with your friends. Thanks in advance
1. Compiler Design Playlist:-- https://www.youtube.com/playlist?list=PLXj4XH7LcRfC9pGMWuM6UWE3V4YZ9TZzM
2. Computer Organization and Architecture Playlist:-- https://www.youtube.com/playlist?list=PLXj4XH7LcRfDXDRzSLv1FfZ-SSA38SiC0
3. Operating Systems Playlist:-- https://www.youtube.com/playlist?list=PLXj4XH7LcRfDrdQuJTHIPmKMpa7eYVaPm
4. C Programming Playlist:-- https://www.youtube.com/playlist?list=PLXj4XH7LcRfBi_vnP7eo-QayXpzuMuOP6
5. Java Programming Playlist:-- https://www.youtube.com/playlist?list=PLXj4XH7LcRfDlQklXu3Hrtru-bm2dJ9Df
6. Data Structures Playlist:-- https://www.youtube.com/playlist?list=PLXj4XH7LcRfAhaLFnq4fQ5ASOqKd08-Us
7. Web Technologies Playlist:-- https://www.youtube.com/playlist?list=PLXj4XH7LcRfCwJmQkWF9sBUFLAdonjOMB
8. C++ Programming Playlist:-- https://www.youtube.com/playlist?list=PLXj4XH7LcRfCmm6ZT-R_33bxLY1fvcm_o
9. DAA ( Design and Analysis of Algorithms) Playlist:-- https://www.youtube.com/playlist?list=PLXj4XH7LcRfAG09GbFgMOLACfvbMplHsW
10. Python Programming Playlist:-- https://www.youtube.com/playlist?list=PLXj4XH7LcRfAKSXjEzeQhXdqTflN7qRlo
11. DMS ( Discrete Mathematical Structures ) Playlist:-- https://www.youtube.com/playlist?list=PLXj4XH7LcRfBB-4hXp4XI84HOCWkaBD63
12. C#.net Playlist:-- https://www.youtube.com/playlist?list=PLXj4XH7LcRfA8sKELgBkkUZxzGK1o5ll0
13. OOP through Python Playlist:-- https://www.youtube.com/playlist?list=PLXj4XH7LcRfANIIqVzBRTh0XDgZxu-QO2
14. LINUX ( UNIX )PROGRAMMING Playlist:- https://www.youtube.com/playlist?list=PLXj4XH7LcRfBiC4yNJ2dnRhE7ShGEB-WQ
/web-app