Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JSP
Search Coderanch
Advance search
Google search
Register / Login
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
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
JSP
How to split a Array value
Ravi Venkar Vaithianathan
Greenhorn
Posts: 6
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi All,
I have this piece of code where I am getting the database values in a
string
array by delimeter ",", then trying to split and store in data base
Code is as follows,
----------------------------------------------------------------------------
<%@ page language="java" import="java.sql.*"%> <%@ page language="java" import="java.util.*"%> <html> <head><title>Business Process Addition</title> </head> <body> <form action="BPAdd.jsp"> <Input Type="Text" Name="BpName"> <p align="center"><b>Following are Records of Activities for Business PRocess.</b><br> </p> <div align="center" width="85%"> <center> <table border="1" borderColor="#ffe9bf" cellPadding="0" cellSpacing="0" width="658" height="63"> <tbody> <td bgColor="#008080" width="47" align="center" height="19"><font color="#ffffff"><b>Sr. No.</b></font></td> <td bgColor="#008080" width="107" height="19"><font color="#ffffff"><b>Activityr ID</b></font></td> <td bgColor="#008080" width="224" height="19"><font color="#ffffff"><b>Activity Name</b></font></td> <td bgColor="#008080" width="270" height="19"><font color="#ffffff"><b>Activity Descriptions</b></font></td> <td bgColor="#008080" width="270" height="19"><font color="#ffffff"><b>Select Activties to BP</b></font></td> <% String DRIVER = "org.gjt.mm.mysql.Driver"; Class.forName(DRIVER).newInstance(); Connection con=null; ResultSet rst=null; Statement stmt=null; try { String url="jdbc:mysql://localhost/MyNewDatabase?user=root&password=123456"; int i=1; con=DriverManager.getConnection(url); stmt=con.createStatement(); rst=stmt.executeQuery("select * from activity"); while(rst.next()){ if (i==(i/2)*2){ %> <tr> <td bgColor="#ffff98" vAlign="top" width="47" align="center" height="19"><%=i%>.</td> <td bgColor="#ffff98" vAlign="top" width="107" height="19"><%=rst.getString(1)%></td> <td bgColor="#ffff98" vAlign="top" width="224" height="19"><Input type="hidden"name="rsta"><%=rst.getString(2)%> </td> <td bgColor="#ffff98" vAlign="top" width="270" height="19"><%=rst.getString(3)%></td> <td bgColor="#ffff98" vAlign="top" width="270" height="19"><Input Type="Checkbox" Name ="Activity" value="<%=rst.getString(1)%>, <%=rst.getString(2)%>"></td> </tr> <% }else{ %> <tr> <td bgColor="#ffff98" vAlign="top" width="47" align="center" height="19"><%=i%>.</td> <td bgColor="#ffff98" vAlign="top" width="107" height="19"><%=rst.getString(1)%></td> <td bgColor="#ffff98" vAlign="top" width="224" height="19"><Input type="hidden" name="rsta"><%=rst.getString(2)%> </td> <td bgColor="#ffff98" vAlign="top" width="270" height="19"><%=rst.getString(3)%></td> <td bgColor="#ffff98" vAlign="top" width="270" height="19"><Input Type="Checkbox" Name ="Activity" value="<%=rst.getString(1)%>, <%=rst.getString(2)%>"></td> </tr> <% } i++; } rst.close(); stmt.close(); con.close(); }catch(Exception e){ System.out.println(e.getMessage()); } %> </tbody> </table> </center> </div> </body> <p> <a href="AActivityAdd.jsp"> Click to Add Activity</a> </p <p> <a href="BPAdd.jsp"> Click to Add Business Process</a> </p <p> <a href="SysAdminHome.jsp"> Click to System Admin Page</a> </p <Input Type="Submit" name="Submit" Value="Submit to Add Business Process"> </form> <% String BpName= request.getParameter("BpName"); String[] selected = request.getParameterValues("Activity"); String[] selected1 = request.getParameterValues("rsta"); if (selected != null && selected.length != 0) { %> <UL> <% for (int i = 0; i < selected.length; i++) { String sid = selected[i]; String aid = selected1[i]; %> <%=sid%> </br> <% } %> <UL> <% } %> </html>
subodh gupta
Ranch Hand
Posts: 203
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You forgot to mention the problem you are facing.
http://subodh-gupta.blogspot.com
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
jsp:include and c:import combination/nesting
Error comes whilke compiling the jsp page
A handy chart for Math class. Check it out.
inserting data to a table
retreiving all rows from a mysql table to a jsp page
More...