Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSF-Questions editable grid in jsp
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Nitin
editable grid in jsp
1 Answer(s)      2 years and 9 months ago
Posted in : Java Server Faces Questions


i want to create editable grid in jsp for invoice so that i can insert multiple product at a same time.how to create that in jsap, plz reply


Advertisement
View Answers

February 11, 2012 at 3:29 PM


We are providing you the code where we have specified only three fields bookid,author and title in the database. Follow these steps to update these fields:

1) Create book.jsp

<%@page import="java.sql.*"%>

<form name=myname method=post action="edit.jsp">
<table border="1">
<tr><td></td>
<td><b><u>bookid</u></b></td>
<td><b><u>Author</u></b></td>
<td><b><u>title</u></b></td>
</tr>
<%try{

Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root", "root");
ResultSet rs = null;
Statement st=null;
st=conn.createStatement();
rs = st.executeQuery("select * from book");
int i=0; while(rs.next()){ %>
<tr><td><input type="checkbox" name="check<%=i%>" value=<%= rs.getString("bookid") %>></td>
<td><%= rs.getString("bookid") %></td>
<td><%= rs.getString("author") %></td>
<td><%= rs.getString("title") %></td>
</tr><%
i++;
}
}catch(SQLException e){ System.out.println(e.getMessage()); } %>
</table>
<input type="submit">
</form>

2) Create edit.jsp

<%@page import="java.sql.*"%>

<%String id[]= new String[10];
for(int i=0;i<10;i++){
id[i]=request.getParameter("check"+i);
out.println(id[i]);
}
%>

<form name=myname method=post action="update.jsp">
<table border="1">
<tr>
<td><b><u>bookid</u></b></td>
<td><b><u>Author</u></b></td>
<td><b><u>title</u></b></td>
</tr>
<%try{

Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root", "root");
ResultSet rs = null;
Statement st=null;
st=conn.createStatement();
for(int a=0;a<10;a++){
rs = st.executeQuery("select * from book where bookid='"+id[a]+"'");
while(rs.next()){ %>
<tr>
<td><input type="text" name="bid" value="<%= rs.getString("bookid") %>"></td>
<td><input type="text" name="auth" value="<%= rs.getString("author") %>"></td>
<td><input type="text" name="tit" value="<%= rs.getString("title") %>"></td>
</tr><%
}
}
}catch(SQLException e){ System.out.println(e.getMessage()); } %>
</table>

<input type="submit">

3)Create update.jsp

<%@page import="java.sql.*"%>
<%
String d[] =request.getParameterValues("bid");
if(d !=null) {
for(int i=0;i<d.length;i++) {
out.println(d[i]);
}
}
String name[] =request.getParameterValues("auth");
if(name !=null) {
for(int i=0;i<name.length;i++) {
out.println(name[i]);
}
}
String title[] =request.getParameterValues("tit");
if(title !=null) {
for(int i=0;i<title.length;i++) {
out.println(title[i]);
}
}
%>
<%
try{
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root", "root");

Statement st=null;
st=conn.createStatement();
for(int a=0;a<10;a++){
String book_id=d[a];
String author=name[a];
String tit=title[a];
st.executeUpdate("update book set author='"+author+"', title='"+tit+"' where bookid='"+book_id+"'");
}
}
catch(Exception e){
e.printStackTrace();
}
%>


Related Tutorials/Questions & Answers:
editable grid in jsp
editable grid in jsp  i want to create editable grid in jsp for invoice so that i can insert multiple product at a same time.how to create that in jsap, plz reply   We are providing you the code where we have specified
jsp grid
jsp grid  In jsp table example the values are not being accepted the error is that the item tag doesn't accept any attributes
Advertisements
Jsp Grid
Jsp Grid  <p>&lt;%@ page language="java" import="java.util....;"></p> <pre class="prettyprint">&lt;title&gt;My JSP...; --&gt; </code></pre> <p><title>jsp paging example
GRID IN JSP - JSP-Servlet
GRID IN JSP  I m creating one ERP project in which i need to fill the data from the data base in a grid in jsp page. So pls any one provide the code
data grid - JSP-Servlet
data grid  how can we implement data grid (we have data grid in asp.net) in jsp. can u please send me the sample code and also the possible ways to implement data grid in jsp Thanks varun kumar  Hi friend, I
data grid - JSP-Servlet
data grid  i am trying to do the example in the following link http://www.roseindia.net/jsp/data-grid.shtml but i am not able to find... this example  Hi friend, To visit again http://www.roseindia.net/jsp/data
editable datagrid
/jsp/data-grid.shtml Here you will get an useful example. Thanks   thanks but i want a editable grid,with the option of modify and delete...editable datagrid  How to create a editable datagrid in jsp,struts1.3
Re:Need Help for Editable Display table - JSP-Servlet
Re:Need Help for Editable Display table  Hi Genius i need a help in jsp to display editable display tag. I able to show the datagrid in jsp... and edit it in the same grid.. Thanks in advance Eswaramoorthy  Hi
Re:Need Help for Editable Display table - JSP-Servlet
Re:Need Help for Editable Display table  Hi Genius
how to display data in List Or grid or in table in Jsp
how to display data in List Or grid or in table in Jsp   <%@page...;JSP Reading Text File</title> </head> <body> <...(); } %> </body> </html> this is my jsp code i want to display
Create Data Grid in JSP page
Create Data Grid in JSP page   ... grid that shows data from database table in jsp page. In this jsp code given... this data grid will fetch data and show in a jsp page. We have used database name
Sigma grid -- Ajax-enabled JavaScript grid
Sigma grid -- Ajax-enabled JavaScript grid       Sigma Grid Sigma Grid is a freely open source AJAX editable data grid, written in pure javascript for displaying and inline
Editable Html
Editable Html  i have editable html table with following elements textbox(n),checkbox(n),sno,dropdownlist..this elements are generated in runtime using javascript by taking the row count from user...now the problem, i dont know
display uploaded file option in editable form
display uploaded file option in editable form  how to show the uploaded file in editable mode on the jsp in struts2.0
display uploaded file option in editable form
display uploaded file option in editable form  how to show the uploaded file in editable mode on the jsp in struts2.0
How to make a horizontally Scrollable grid in jsp using div, table, css, javascript?
How to make a horizontally Scrollable grid in jsp using div, table, css, javascript?  In a jsp page InsertUpdate.jsp (say) there is a button Insert... saving data would be viewed in grid in the same page. Now problem is that, I need
Ajax grid
Ajax grid  Hi, How I can create ajax grid in my program? Thanks
how to use an editable combobox
how to use an editable combobox   Hello Everyone!!!!!!!! I have a jcombo box with certain values and i want to use it as an editable that means when user will type something in combobox, according to that text only matching item
editable combobox method selection
editable combobox method selection  how to make an editable combobox that shows nothing initially but as a key is pressed it pops up and selects an item starting with that letter, subsequent keys would keep sorting from the list
Editable JTree
Editable JTree Nodes        In this section, you will learn  to make JTree editable...: This program constructs a JTree that contains editable nodes. Firstly, it defines
HTML GRID
HTML GRID  how to retrieve data from mysql database in grid form using html and servlets? urgent....   import java.io.*; import java.sql....); } out.println("<html><h3>Pagination of JSP page</h3><body><
Java with Grid - Ajax
/aspnet-ajax/grid/examples/hierarchy/nestedviewtemplate/defaultcs.aspx grid.... thanks.  Hi Friend, You can use jsp / servlet. For code, please visit the following links: http://www.roseindia.net/jsp/data-grid.shtml http
Nitobi Grid is not working in IE10/IE11
Nitobi Grid is not working in IE10/IE11  Nitobi grid is working in IE8, but not working in IE10/IE11. we are using above two javascript files to open the grid
Problem With Combo Box Editable Property
Problem With Combo Box Editable Property  Hi I am new To Flex i had set Combo Box Editable Property as true. But I didn't get the property filtering in the combo box like when you enter text "S" in the combo box then the names
How to export grid into excel
How to export grid into excel  Hi, i created a grid panel i have to export it to the excel. please help me by some sample code. thanks in advance. cool day dude
java + grid - Java3D
java + grid  i need to give the output of the application in the form of a grid in XY-plane,the grid should have different colors for regions of different value range
Grid Problem - Java Beginners
Grid Problem  Hi Deepak Plz take seriously I m telling u detail. Steps: 1:- there r one form,this form belong to grid. and two... belong to different table.but in main form,all data going in the grid(with join
i want to create invoice report editable. values should be taken from dabase and editable .. help out asap
i want to create invoice report editable. values should be taken from dabase and editable .. help out asap   i want to create invoice report editable. values should be taken from dabase and editable .. help out asap
give me a grid example in php
give me a grid example in php  give me easy code example of grid in php like mysql editor
add row in grid using dojo
add row in grid using dojo  add row in grid using dojo
Grid rows delete issue
Grid rows delete issue  I have a grid having rows with Remove button to remove rows,But we also havae an facility to remove those rows on onchange event of dropdown also,so if we delete middle row and then remove all rows
Advertisements
 

 

 

DMCA.com