How to Use Jstl(JSP Standard Tag Library) Sql tag

 

Using   Tag Library To Retrieve Data From The Data Base   

  Before Implementing Import Jstl.jar                            

 

<%@ page import=”java.io.*,java.util.*,java.sql.*”%>
<%@ page import=”javax.servlet.http.*,javax.servlet.*” %>
<%@ taglib uri=”http://java.sun.com/jsp/jstl/core&#8221; prefix=”c”%>
<%@ taglib uri=”http://java.sun.com/jsp/jstl/sql&#8221; prefix=”sql”%>
 
<html>
<head>
<title>Retrieving Using Sql Tag </title>
</head>
<body>
 
<sql:setDataSource  driver=”com.mysql.jdbc.Driver” url=”jdbc:mysql://localhost:3306/LOGIN” user=”root”  password=”root”   />

<sql:query var=”result”  >
   SELECT * from register;
</sql:query>
 
<table border=”1″ width=”100%”>
<tr>
   <th>UserId</th>
   <th>Username</th>
   <th>Phoneno</th>
   <th>Email</th>
</tr>
<c:forEach var=”row” items=”${result.rows}”  >
<tr>
   <td><c:out value=”${row.userid}”/></td>
   <td><c:out value=”${row.username}”/></td>
   <td><c:out value=”${row.phoneno}”/></td>
   <td><c:out value=”${row.email}”/></td>
</tr>
</c:forEach>
</table>
 
</body>
</html>

 

 

 

Thanks & Regards

K.RAJ SEKHAR REDDY

(software Developer )

 

 

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s