• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How to save values in a database in JSTL?

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can I store values in a database using JSTL...
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Palani Kumar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
<x:out select="$result/AirportName" />
</td>
<td>
<x:out select="$result/Location" />
</td>
<td>
<x:out select="$result/ByBus" />
</td>
<td>
<x:out select="$result/ByTaxi" />
</td>
<td>
<x:out select="$result/ByTrain" />
</td>
<td>
<x:out select="$result/PhoneNum" />
</td>
<td>
<x:out select="$result/Website" />
</td>
</tr>
</x:forEach>
</table>
</body>
</html>
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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
 
Palani Kumar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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="jdbc:odbc: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>
<x:out select="$a" />
</td>
</tr>

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

<td>
<x:out select="$b" />
</td>
</tr>

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

<td>
<x:out select="$c" />
</td>
</tr>
</table>

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

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

</table>
</body>
</html>
[ May 30, 2008: Message edited by: Palani Kumar ]
 
You may have just won ten million dollars! Or, maybe a tiny ad.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic