Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Home Answers Viewqa JSP-Servlet How to store values in a database using JSTL?

View Questions and Answers by Category


Have Programming Question? Ask it here!

How to store values in a database using JSTL?
1 Answer(s)      6 years and 7 months ago
Posted in : JSP-Servlet

View Answers

May 29, 2008 at 7:49 PM

Hi friend,

<title>Insert data in database using JSTL</title>
<table border="1" width="75%">
<body bgcolor=lightpink>
<table border="1" width="100%" callspacing="0" cellpadding="0">
<form method=post action="query.jsp">
<input type=text name='text1'>name<br>
<input type=text name='text2'>number<br>
<input type=text name='text3'>Position<br>
<select name=combo1>
<option value="add">add
<option value="delete">delete

<input type=submit name="submit" value="Submit">



<%@ taglib prefix="c" uri=""; %>
<%@ taglib uri=""; prefix="sql" %>

<sql:setDataSource var="db" driver="jdbc:mysql://"; url="com.mysql.jdbc.Driver" />

<c:set var="a" value="${param.text1}" />
<c:set var="b" value="${param.text2}" />
<c:set var="c" value="${param.text3}" />
<c:set var="d" value="${param.combo1}" />

<c:if test="${d == 'add'}" >
<sql:update var="query1" dataSource="${db}" sql="insert into empdetail values${a}','${b}')">
<c:out value="record added"/>

<c:forEach var="row" tems="${query1.rows}" >
<c:set var="n" value="OK" />
<td> <c:out value="${}" /></td>
<td> <c:out value="${}" /></td>
<c:if test="${n != 'OK'}" >
<c:out value="No such Records" />


Read for more information.

Related Tutorials/Questions & Answers: