View Answers

August 28, 2008 at 6:06 PM

Hi friend,


i am sending simple program.


<html>
<head>
<title>Insert data in database using JSTL</title>
</head>
<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

</select>
<br>
<input type=submit name="submit" value="Submit">

</table>
</from>
</body>
</table>
</html>

------------------------------------------

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core";; %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql";; prefix="sql" %>


<html>
<body>
<sql:setDataSource var="db" driver="jdbc:mysql://192.168.10.211:3306/";; 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}')">
</sql:update>
<c:out value="record added"/>
</c:if>

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

-------------------------------------

Read for more information.

http://www.roseindia.net/jsp/

Thanks.

August 28, 2008 at 9:32 PM

Dude thanks for the help. You have just recreated all my code. Good job. I knew how to do all that but when I get all that data brought back to the screen in a tabular column I want to choose a row and send that info to another program then after done come back to this calling page with the proper row I was on. Dont know how to put that row into the <c:forEach> statement. If your willing to help I will make an example table and system to display the data and show you what I mean. It will take me a short time to do so though. Just let me know. Thanks for the try.
v/r Bill









Related Tutorials/Questions & Answers:

Ads