How to store values in a database using JSTL?

Ads
 

How to store values in a database using JSTL?

View Answers

May 29, 2008 at 7:49 PM

Hi friend,


<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/

Ads









Related Tutorials/Questions & Answers:
how to store multiple values from drop down in database where i am using java struts 1.3
How to show database values into graph using jsp?
Advertisements
How to show database values into graph using jsp?
How to create bar chart using database values
how can i store text box values as it is in database table
how to store and retrieve images int and from the database using php
store dropdown box values in database server
how to read values from excel sheet and compare with database using jsp
How to insert dynamic textbox values into database using Java?
how to display values from database into table using jsp
How I Upload File and Store that file name in Database using JSP
How to store image into database
How to store an image in database
store values of drop down list box in database
How to get the text from textarea in HTML and store it in database using javascript and jsp
how to store image in folder and stored image path in mysql database using JSP
How to store user name,city,state,image path into database and image into folder using jsp
edit values of database using jsp
edit values of database using jsp
How to store multiple images in folder and images path in database at a time using jsp?
How To Store Multilple Images In MySQL database dynamically with image uploader and then retrieve them in image gallery using java
how to read the values for text and csv files and store those values into database in multiple rows..means one value for one row
How to store unique values in Java using Set?
How to store unique values in Java using Set?
How to show autocomplete textbox values on combo box option selection using database?
Store values of dynamically generated textboxes into database
How To Store Image Into MySQL Using Java
How to Store Image using JSF
How to store and retrieve image from database in JSP?
Retrieve values from database using views
how to store and retrieve image from database

Ads