How to store values in a database using JSTL?

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/









Related Tutorials/Questions & Answers:
How to store values in a database using JSTL? - JSP-Servlet
how to store multiple values from drop down in database where i am using java struts 1.3
Advertisements
How to store extracted values from xml in a database? - XML
How to store extracted values from xml in a database? - XML
How to show database values into graph using jsp?
How to show database values into graph using jsp?
how can i store text box values as it is in database table
How to create bar chart using database values
store dropdown box values in database server
store values of drop down list box in database
how to store and retrieve images int and from the database using php
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
edit values of database using jsp
edit values of database using jsp
How to store image into database
How to edit values in textboxes from database using jsp
Store values of dynamically generated textboxes into database
How to store unique values in Java using Set?
How to store unique values in Java using Set?
How to get the text from textarea in HTML and store it in database using javascript and jsp
how to store image file and videofile in ms access database using java? - JDBC
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
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 an image in database
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
Retrieve values from database using views
How to show autocomplete textbox values on combo box option selection using database?
How To Store Image Into MySQL Using Java
how to store a dynamic values - JSP-Servlet
Navigate database values using up and down key of keyboard
How to Store Image using JSF
How to store and retrieve image from database in JSP?
how to store and retrieve image from database
how to store and then immediately retrieve when store the image into database?
How to store JComboBox item into database
how to store array values into two different tables in java?
how to display the database values in pdf format
graph generation using jfreechart and retrieving values from the database
How to store two integer value in a separate file and retrieve those values
Create Line Graph using database values
how to store image upload path to mssql database
how to store image upload path to mssql database
how to store image upload path to mssql database
how to store image upload path to mssql database
How to values from xml using java?

Ads