Jsp Grid
1 Answer(s)      6 years and a month ago
Posted in : JSP-Servlet
<p>&lt;%@ page language="java" import="java.util.<em>,</em>,*" pageEncoding="ISO-8859-1"%>
&lt;%@ page contentType="text/html"%>
&lt;%@ page import="org.apache.taglibs.datagrid.DataGridParameters"%> 
&lt;%@ page import="java.sql.*"%>
&lt;%@ taglib uri="" prefix="ui" %>
&lt;%@ taglib uri="" prefix="c" %>
&lt;%@ taglib uri="" prefix="fmt" %>
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <base href="&lt;%=basePath%>"></p>

<pre class="prettyprint">&lt;title&gt;My JSP 'page.jsp' starting page&lt;/title&gt;

&lt;meta http-equiv="pragma" content="no-cache"&gt;
&lt;meta http-equiv="cache-control" content="no-cache"&gt;
&lt;meta http-equiv="expires" content="0"&gt;    
&lt;meta http-equiv="keywords" content="keyword1,keyword2,keyword3"&gt;
&lt;meta http-equiv="description" content="This is my page"&gt;
&lt;link rel="stylesheet" type="text/css" href="styles.css"&gt;

<p><title>jsp paging example in datagrid</title>
th a:link { text-decoration: none; color: black }
th a:visited { text-decoration: none; color: black }
.rows { background-color: white }
.hiliterows { background-color: pink; color: #000000; font-weight: bold }
.alternaterows { background-color: #efefef }
.header { background-color: cyan; color: #000000;font-weight: bold }</p>

<p>.datagrid { border: 1px solid #C7C5B2; font-family: arial; font-size: 9pt;
font-weight: normal }

<p><span align="center" style="padding-left:250px;font-size:20px;"></span>
&lt;% ArrayList promptList = new ArrayList ();
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
Announcements announce = new Announcements ();
int fromIndex, toIndex;
int tcount =0;
int perpage=4;
int tpage=0;
try {</p>

<p>preparedStatement = connection.prepareStatement("SELECT * from global_announcements");
resultSet= preparedStatement.executeQuery();
while ( { 

catch (SQLException sqlException) {
System.out.println("Unable to connect to batabase."+sqlException);
fromIndex = (int) DataGridParameters.getDataGridPageIndex (request, "datagrid1");
if ((toIndex = fromIndex+4) >= promptList.size ())
toIndex = promptList.size();
request.setAttribute ("promptList", promptList.subList(fromIndex, toIndex));</p>

<p>pageContext.setAttribute("tCount", tcount);

<p><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
&lt;%String promptlist=(String)request.getAttribute("promptList"); %>
<ui:dataGrid items="&lt;%=promptlist%>" var="prompt" name="datagrid1" cellPadding="0" 
cellSpacing="0" styleClass="datagrid" >

<p><column width="50">
<header value="" hAlign="left" styleClass="header"/></p>


<p><column width="200">
<header value="PromptId" hAlign="left" styleClass="header"/>
<item value="&lt;%=announce.getPromptId()%>" hAlign="left" 

<column width="200">
<header value="PromptDescription" hAlign="left" styleClass="header"/>
<item value="&lt;%=announce.getPromptDescription()%>" hAlign="left" styleClass="item"/></p>

<column width="200">
<header value="StartDate" hAlign="left" styleClass="header"/>
<item value="&lt;%=announce.getStartDate()%>" hAlign="left" styleClass="item"/></p>


<p><column width="100">
<header value="EndDate" hAlign="left" styleClass="header"/>
<item value="&lt;%=announce.getEndDate()%>" hAlign="left" styleClass="item"/></p>


<p><column width="100">
<header value="Status" hAlign="left" styleClass="header"/>
<item value="&lt;%=announce.getStatus()%>" hAlign="left" styleClass="item"/></p>


<rows styleClass="rows" hiliteStyleClass="hiliterows"/>
<alternateRows styleClass="alternaterows"/></p>

<p><paging size="4" count="request.getAttribute{tCount}" custom="true" nextUrlVar="next" 
previousUrlVar="previous" pagesVar="pages"/>
<order imgAsc="up.gif" imgDesc="down.gif"/>

<table width="750" style="font-family: arial; font-size: 10pt" border=0>

<td align="left" width="33%">
<c:if test="${previous != null}">
<a href="<c:out value="${previous}"/>">Previous</a>
<td align="center" width="33%">
<c:forEach items="${pages}" var="page">
<c:when test="${page.current}">
<b><a href="<c:out value="${page.url}"/>"><c:out value="${page.index}"/></a></b>
<a href="<c:out value="${page.url}"/>"><c:out value="${page.index}"/></a>
<td align="right" width="33%">&nbsp;
<c:if test="${next != null}">
<a href="<c:out value="${next}"/>">Next</a>

</html> </p>


View Answers

February 3, 2011 at 5:49 PM

Hi Friend,

Please visit the following links:

Hope that the above links will be helpful for you.


Related Tutorials/Questions & Answers:
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
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  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 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
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 to create that in jsap, plz reply   We are providing you the code where we have specified
data grid - JSP-Servlet
data grid  i am trying to do the example in the following link but i am not able to find... this example  Hi friend, To visit again
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
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
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
HTML GRID  how to retrieve data from mysql database in grid form using html and servlets? urgent....   import*; 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
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
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
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
Nitobi Grid V3
Nitobi Grid V3       Display & edit tabular data in various web browsers(IE, Firefox & Netscape) with Ajax-powered Nitobi Grid V3. With minimal coding, Grid delivers responsive
count asterisk in a grid - Java Beginners
count asterisk in a grid  I need to write a program that uses a recursive method to count the number of asterisk in a square grid
how to insert a summary values in grid
how to insert a summary values in grid  how to insert a summary value in grid
Grid in Echo3
Grid in Echo3       Grid is a two-dimensional structure on which the designers and developers can organize their components in a well and easy to understand manner. Grid class
Grid layout container
Grid layout container       Grid container places the child components in columns and rows. This is very similar to html tables. Inside the Grid tag, GridRow tag is used to represent
grid view in java - Java Beginners
grid view in java  Is it possible to create dynamic grid view to display data from database. if yes. how ??   Hi Friend, Yes, you can. Try the following: import java.awt.*; import java.sql.*; import
data grid with edit and delete options at each row.
data grid with edit and delete options at each row.  i want to display the table data in the format of data grid with edit and delete options at each row. i need it very urgently. advance thanks
Setting Grid Line in JTable
Setting Grid Line in JTable     ... JTable that contains predefined grid line with black color. But in this Java programming tutorial, you will learn how to set the colored grid line in JTable
Grid World project Run Error !! help please!!
Grid World project Run Error !! help please!!  i'm trying to make... itself from the grid and add 2 bugs to a empty location. It "steps" but does... where to put the bug on the grid Random randomGenerator = new Random
dojo grid from 3 different sources
dojo grid from 3 different sources  I'm new with dojo. I need to get data from 3 different database tables and diplay them on the browser (maybe a grid) and show friends (name+img) of the logged in user with the title
How to use struts2 grid with form submission
How to use struts2 grid with form submission  Hello, I've already...; > <div class="gridSection"> > <sjg:grid... submitted successfully, action also executed successfully, but the grid becomes