This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JSP and the fly likes How to save values in a database  in JSTL? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to save values in a database  in JSTL?" Watch "How to save values in a database  in JSTL?" New topic
Author

How to save values in a database in JSTL?

Palani Kumar
Greenhorn

Joined: May 28, 2008
Posts: 13
How can I store values in a database using JSTL...
Prasad Tamirisa
Ranch Hand

Joined: Mar 26, 2007
Posts: 130
Did you come across SQL library of JSTL? That is exclusively designed for your purpose.

You may also what to check the following links for more information.

link1
link2
link3

[ May 29, 2008: Message edited by: Prasad Tamirisa ]
[ May 29, 2008: Message edited by: Prasad Tamirisa ]

Regards,
Durga Prasad
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41633
    
  55
Hello Kumar-

Welcome to JavaRanch.

On your way in you may have missed that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.

As to your question, it's considered bad design to perform JDBC operations in JSPs, with or without JSTL. Consider using a backing bean or -even better- a servlet instead.


Ping & DNS - my free Android networking tools app
Palani Kumar
Greenhorn

Joined: May 28, 2008
Posts: 13
Here is my code i cant insert values into database... pls help me

<%@ page import="java.io.*"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/xml" prefix="x" %>
<html>
<head>
<title>Airport</title>
</head>
<body>
<c:import var="students" url="http://service.openkapow.com/palanikumar/airportbarbados.rest" />
<x:parse var="doc" xml="${students}" />
<table border="1">
<tr>
<th>AirportName</th>
<th>Location</th>
<th>Airport Overview</th>
<th>ByBus</th>
<th>ByTaxi</th>
<th>ByTrain</th>
<th>PhoneNum</th>
<th>Website</th>
</tr>
<x:forEach var="result" select="$doc/result">
<tr>
<td>
<xut select="$result/AirportName" />
</td>
<td>
<xut select="$result/Location" />
</td>
<td>
<xut select="$result/ByBus" />
</td>
<td>
<xut select="$result/ByTaxi" />
</td>
<td>
<xut select="$result/ByTrain" />
</td>
<td>
<xut select="$result/PhoneNum" />
</td>
<td>
<xut select="$result/Website" />
</td>
</tr>
</x:forEach>
</table>
</body>
</html>
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41633
    
  55
The page doesn't contain any JDBC/SQL code, so I'm not sure how it could insert anything in a DB?
[ May 29, 2008: Message edited by: Ulf Dittmer ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61105
    
  66

"Kumar Ranch", you have previously been warned on multiple occasions regarding adjusting your display name to meet JavaRanch standards. This is not optional, and this is your final warning. Adjust your display name to comply with the required standards prior to your next post.

Failure to comply will result in the removal of your account.

bear
JavaRanch Sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Palani Kumar
Greenhorn

Joined: May 28, 2008
Posts: 13
This is my code... This is not inserting values into database... Whts wrong in my code... Pls help me..
<?xml version="1.0" encoding="ISO-8859-1"?>
<students>
<student id="1">
<name>
<first>Joe</first>
<last>Y</last>
<middle>T</middle>
</name>
<grade>
<points>99</points>
<letter>A</letter>
</grade>
</student>
<student id="2">
<name>
<first>James</first>
<last>Todd</last>
<middle>K</middle>
</name>
<grade>
<points>92</points>
<letter>B</letter>
</grade>
</student>
<student id="3">
<name>
<first>Kate</first>
<last>Wang</last>
<middle>A</middle>
</name>
<grade>
<points>72</points>
<letter>C</letter>
</grade>
</student>

</students>

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/xml" prefix="x" %>
<html>
<head>
<title>Set Examples</title>
<sql:setDataSource driver="sun.jdbc.odbc.JdbcOdbcDriver" url="jdbcdbc:db1" var="db1" />

</head>

<body>
<c:import var="students" url="students.xml" />

<x:parse var="doc" xml="${students}" />

<x:set var="a" select="$doc/students/student/name/first" />

<x:set var="b"
select="$doc/students/student/name/last" />

<x:set var="c"
select="$doc/students/student/name/middle" />

<table border="1">
<tr>
<td>$doc/students/student/name/first</td>

<td>
<xut select="$a" />
</td>
</tr>

<tr>
<td>$doc/students/student/name/last</td>

<td>
<xut select="$b" />
</td>
</tr>

<tr>
<td>$doc/students/student/name/middle</td>

<td>
<xut select="$c" />
</td>
</tr>
</table>

<sql:update var="query1" dataSource="${db1}" sql="insert into studentDetails

values('${a}','${b}')">
</sql:update>
<cut value="record added"/>
<c:forEach var="row" items="${query1.rowsByIndex}" >
<tr>
<td> <cut value="${row.first}" /></td>
<td> <cut value="${row.last}" /></td>
<td> <cut value="${row.middle}" /></td>
</tr>
</c:forEach>

</table>
</body>
</html>
[ May 30, 2008: Message edited by: Palani Kumar ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to save values in a database in JSTL?