Pages Navigation Menu

Coding is much easier than you think

Pagination in Struts 2 Using display tag

 
pagination in struts 2
 
In Struts 2 Pagination can be implemented with the help of Displaytag. This tag can handle feature such as pagination, sorting and exporting of a table. In the following example we will see how to display data using display tag and to do pagination, sorting and exporting.
 
** UPDATE: Struts 2 Complete tutorial now available here.
 
Download the Latest version of displaytag.jar here
 
Now Create a Dynamic web project and make sure that you have the following libraries are in your WEB-INF/lib directory.

commons-beanutils-1.8.0.jar
commons-collections-3.1.jar
commons-digester-2.0.jar
commons-io-2.0.1.jar
commons-lang-2.4.jar
commons-lang3-3.1.jar
commons-logging-1.1.1.jar
commons-logging-api-1.1.jar
displaytag-1.2.jar
freemarker-2.3.19.jar
ognl-3.0.6.jar
struts2-core-2.3.8.jar
xwork-core-2.3.8.jar

displaytag-export-poi.jar is used to export the files in xls,csv or xml format.
 


 
Action Class
 
StudentAction.java

package com.simplecode.action;

import java.util.ArrayList;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.simplecode.form.StudentBean;

public class StudentAction extends ActionSupport 
{
private static final long serialVersionUID = 1L;
private List<StudentBean> students = new ArrayList<StudentBean>();

public String displayStudentList() 
{
	students.add(new StudentBean("o7bb002", "Gokul", "ECE", 4));
	students.add(new StudentBean("o7bc074", "Muthu Vijay", "CSE", 6));
	students.add(new StudentBean("o7bb040", "Jaya Prakash", "ECE", 10));
	students.add(new StudentBean("o7bc055", "Mohiadeen", "CSE", 7));
	students.add(new StudentBean("o7bd047", "HariPriya", "IT", 1));
	students.add(new StudentBean("o7bd024", "Pavithra", "IT", 3));
	students.add(new StudentBean("o7bb009", "Aswin", "ECE", 8));
	students.add(new StudentBean("o7ba029", "Sharmila", "IT", 11));
	students.add(new StudentBean("o7ba027", "Nilafar", "IT", 2));
	students.add(new StudentBean("o7bd081", "Dinesh Babu", "MECH", 13));
	students.add(new StudentBean("o7ba062", "Lourde", "MECH", 9));
	students.add(new StudentBean("o7bc079", "Nisha", "CSC", 5));
	students.add(new StudentBean("o7bb039", "Guru Prasad", "MECH", 12));
	students.add(new StudentBean("o7bc033", "Gowtham Raj", "CSE", 15));
	students.add(new StudentBean("o7bb039", "Ibrahim Sha", "ECE", 14));
	students.add(new StudentBean("o7bd081", "Dinesh Babu", "MECH", 16));

	return SUCCESS;
}

public List<StudentBean> getStudents() 
{
	return students;
}

public void setStudents(List<StudentBean> students) 
{
	this.students = students;
}
}

 
StudentBean.java
 

package com.simplecode.form;

public class StudentBean 
{
private String rollNo;
private String studentName;
private String department;
private int rank;

public StudentBean(String rollNo, String studentName, String department, int rank) 
{
    this.rollNo = rollNo;
    this.studentName = studentName;
    this.department = department;
    this.rank = rank;
}
public String getRollNo() 
{
	return rollNo;
}
public void setRollNo(String rollNo) 
{
	this.rollNo = rollNo;
}
public String getStudentName() 
{
	return studentName;
}
public void setStudentName(String studentName) 
{
	this.studentName = studentName;
}
public String getDepartment() 
{
	return department;
}
public void setDepartment(String department) 
{
	this.department = department;
}
public int getRank() 
{
	return rank;
}
public void setRank(int rank) 
{
	this.rank = rank;
}
}

 
displaytag.jsp
 


<%@taglib prefix="s" uri="/struts-tags"%>
<%@taglib prefix="display" uri="http://displaytag.sf.net"%>

<title>Students Details</title>
<style type="text/css">

/* for hiding the page banner */
.pagebanner 
{
	display: none;
}
/* for customizing page links */
.pagelinks 
{
	color: maroon;
	margin: 20px 0px 20px 50px;
}
/* for shifting all the Export options*/
.exportlinks 
{
	margin: 20px 0px 20px 30px;
}
/* For changing the spaces between export link */
.export 
{
	margin-left: 30px;
}
/* For Table css */
table 
{
	border: 1px solid #666;
	width: 60%;
	margin: 20px 0 20px 0px;
}
/* For odd and even row decoration */
tr.odd 
{
	background-color: #fff
}
tr.tableRowEven,tr.even 
{
	background-color: #CCCCCC
}
/* Css for table elements */
th,td 
{
	padding: 2px 4px 2px 4px;
	text-align: left;
	vertical-align: top;
}
thead tr 
{
	background-color: #999999;
}
/* For changing the background colour while sorting */
th.sorted 
{
	background-color: #CCCCCC;
}
th.sorted a,th.sortable a 
{
	background-position: right;
	display: block;
	width: 100%;
}
th a:hover 
{
	text-decoration: underline;
	color: black;
}
th a,th a:visited 
{
	color: black;
}
</style>

<html>
<body>
<display:table id="studentTable" name="students" pagesize="5" cellpadding="5px;"
cellspacing="5px;" style="margin-left:50px;margin-top:20px;" requestURI="">
<display:column property="rollNo" title="Roll No"/>
<display:column property="studentName" title="Student Name"/>
<display:column property="department" title="Department"/>
<display:column property="rank" title="Rank"/>
</display:table>
</body>
</html>

 
Questions:

How to make Struts 2 tag work inside Display tag?
How to get checkbox values from displaytag using struts2
Displaytag export option is not working?
 
struts.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="default" extends="struts-default">
<action name="displayStudentList" class="com.simplecode.action.StudentAction" 
                  method="displayStudentList">
   <result name="success">/displaytag.jsp</result>
</action>
</package>
</struts>

 
After executing the project, you will get the following output:
 
pagination
 
Recommended reading :

  • AJAX implementation in Struts 2 using JQuery and JSON
  • Gridview in Struts2 using jQuery DataTable
  • CRUD Operations in Struts 2 using jTable jQuery plugin via Ajax
  •  
    Auto-sorting
     
    If you want to allow the user to sort the data displayed then set the attribute sortable=”true” on the display:column tag that you want to sort by.
     

    <display:column property="rollNo" title="Roll No" sortable="true"/>
    <display:column property="studentName" title="Student Name" sortable="true"/>
    <display:column property="department" title="Department" sortable="true"/>
    <display:column property="rank" title="Rank" sortable="true"/>
    

     
    Now on clicking the rank header the student resultset are sorted according to rank as shown below.

    sort in pagination
     
    Here the problem is whenever we sort the table by clicking on any sortable column header it only sort the data visible in that page. We can override this behavior by setting sort attribute in column to list as shown below.
     

    <display:table export="true" id="studentTable" name="students" pagesize="5" cellpadding="5px;"
    cellspacing="5px;" style="margin-left:50px;margin-top:20px;" requestURI="" sort = "list">
    

     

    So now when you click on sort, the data will be sorted based on whole list.
     
    sort
     
    Data exporting
     
    When you set the Table Tag’s export attribute to “true”, footer will appear below the sorted result, which will allow you to export the data being shown in various formats(CSV, XLS, and XML).
     
    ** UPDATE: Struts 2 Complete tutorial now available here.
     

    <display:table export="true" id="studentTable" name="students" pagesize="5" cellpadding="5px;"
    cellspacing="5px;" style="margin-left:50px;margin-top:20px;" requestURI="">
    

     
    export on pagination
     
    Suppose if you want to place the banner at bottom , then you can use the following code, within the display-table tag

    <display:setProperty name="paging.banner.placement" value="bottom" />
    

     
    ** Update — The below screenshot is the demo of pagination in struts 2 via ajax using using jQuery jTable plugin, this plugin has several inbuilt theme and lot may cool features like crud implementation via ajax, internalization etc, to know more about this plugin, please refer the article here.
     
    Struts-2-jTable-jQuery-plug-in-Create-record-animation-effect
     

    download
     

    About Mohaideen Jamil


    Am currently working as a Struts 2 Developer in a reputed IT Organisations. I can help you with teaching Core java and Struts 2. Follow me on Facebook or Google Plus. If you like my tutorials, consider making a donation to this charity, thanks.

    • சிவ கிரி

      hi i need Spring web MVC Program with hibernate in need like dropdown menu Country->state->District how to do with Spring Webmvc +hibernate+mysql if u have any program give me a link dude ..I was searching more than one week in net ..finally i found u r site but it helped me a lot for struts ..i need for spring ?? can u help me my mail id testing.freshers@gmail.com @Mohaideen:disqus

    • Anh

      Can integrate Struts tiles with jTable?

      • Mohaideen Jamil

        Yes

    • amit

      how we can use check box in within display tags for showing result.

    • https://plus.google.com/109599654675420857375 sampath mende

      HI Jamil,

      Can you please how to implement display tags paginatedlist since i want to fetch records for each page click.In the example its not there,can you share sample code or share the approach how to implemnt that using spring mvc
      Thanks,
      Sampath

    • http://simplecodestuffs.com Vaibhav Nandkule

      (looking for struts2 and hibernate pagination integration)
      hi,i am using and in background as hibernate. and i am having more than 35000 employee record
      then how do you handle that 35000 object and how it will fetch only pagesize record. kindly mention your ans with code if possible……

    • sivagiri

      i need to show the search list like 10th result

      how can we do in Struts2 using mysql ?? i need your help

    • Ahamed

      Hi Guys,

      I am getting Arabic data as UTF-8 format in download Excel. can any one help to fix the issue. i am using Struts 2 for this.

    • Priti

      Hi, I need a help on pagination. After implementing display tag it is showing 1-8 pages link in the top and botton of the page as pagination link..I want to change this to 10..so that 10 pagination numbers will be displayed and i can nevigate to 1-10 pages..Could you pls help me how to do this.

      • http://www.simplecodestuffs.com Mohaideen Jamil

        Hi,

        Those numbers are generated based on number of records present in your sisplay tag list ..

        For example if your list size is 80 and page size is 10 , then only 1- 8 link will be displayed ..

        These numbers are genarated dynamically based on list size, and to my knowledge you wont have any controll over it.

        • Priti

          Hi. Thanks for your reply. After I have posted my query here, I have searched for the solution and found it..And it is working fine now..

          Here is the solution.
          We need to use
          10
          inside the
          The number 10 can be any no. If we won’t specify this property, display tag bydefault sets 8 internally..Now if we specify we will get 10 pages link in the pagination bar.

          Hope this will be helpful who needs it.

          • Priti

            Sorry for the comments above..I posted the code but it didnt show in comments. Anyhow I willl describe here.. we need set display property paging.banner.group_size value to 10.

          • http://www.simplecodestuffs.com Mohaideen Jamil

            Hi Thanks for your information. But can you please post your code inside [code ] [/code] tag…

          • Priti

            not able to post code still..getting exception while posting

    • NansJames

      Hi, Thanks for your post. i need to display image from a folder inside displaytag according to the iteration of the display column.


      <img border="0" src="” width=”80″ height=”70″>

      can i do this… problem i can get all the images from struts2 inputstream so am storing in local folder and getting from there. please help… i have to solve this issue.

      • http://www.simplecodestuffs.com Mohaideen Jamil

        Hi ,

        Yes you can implement this.

        But you cant fetch all images via input stream. So better go for local folder option.

        • NansJames

          Isn’t possible to get images (multiple) directly from database through struts2 without local folder?

    • Moe

      Hi, I wonder If I already have a table like this, how can I do with diplay tag. I have Action class, Dao Class and Model Class

      Name
      Roman Name
      Address
      DOB

      • http://www.simplecodestuffs.com Mohaideen Jamil

        please post your code inside [code ] tags

    • Anand

      Thanks for the quick response Jamil, appreciate it.

      Will check on the special character thing.

    • suresh

      Hi jamal,
      while moving from 1st page to another page i am facing the below error in console.But i m getting the expected output.I am not passing any special characters and all.

      Aug 15, 2014 1:13:15 PM com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
      WARNING: Error setting expression ‘id’ with value ‘[Ljava.lang.String;@17cc075′
      ognl.MethodFailedException: Method “setId” failed for object Action.EmployeeAction@123598 [java.lang.NoSuchMethodException: Action.EmployeeAction.setId([Ljava.lang.String;)]
      at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1265)
      at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1454)
      at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85)
      at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162)
      at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:28)
      at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2225)
      at com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor.setProperty(CompoundRootAccessor.java:65)
      at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2225)
      at ognl.ASTProperty.setValueBody(ASTProperty.java:127)
      at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
      at ognl.SimpleNode.setValue(SimpleNode.java:301)
      at ognl.Ognl.setValue(Ognl.java:737)
      at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:198)
      at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:161)
      at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:149)
      at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:276)
      at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:187)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
      at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
      at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
      at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:279)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
      Caused by: java.lang.NoSuchMethodException: Action.EmployeeAction.setId([Ljava.lang.String;)
      at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1206)
      … 68 more
      /– Encapsulated exception ————\
      java.lang.NoSuchMethodException: Action.EmployeeAction.setId([Ljava.lang.String;)
      at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1206)
      at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1454)
      at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85)
      at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162)
      at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:28)
      at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2225)
      at com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor.setProperty(CompoundRootAccessor.java:65)
      at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2225)
      at ognl.ASTProperty.setValueBody(ASTProperty.java:127)
      at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
      at ognl.SimpleNode.setValue(SimpleNode.java:301)
      at ognl.Ognl.setValue(Ognl.java:737)
      at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:198)
      at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:161)
      at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:149)
      at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:276)
      at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:187)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
      at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
      at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
      at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
      at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:279)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
      \————————————–/

      In the address bar i am getting the below,while transfering
      http://localhost:8082/Struts2.0DISPLAYTAGwithEDITandDELETE/delete?id=93&d-49653-p=2

      Please help me to solve this.

      • http://www.simplecodestuffs.com Mohaideen Jamil

        It is worth noting the stack trace is a Warning, not an Error.

        Also, the Warning is not thrown when the form field is actually populated with a value in it. Only when the form field is empty the Warning and stack trace thrown.

        Therefore, we can either ignore the Warning since it is not doing us any harm or default the Id to some numeric value and then add logic in our Action class to deal with it.

        To ignore the warning you need to adjust the log4j level accordingly:

        # Struts OgnlUtil issues unimportant warnings
        log4j.logger.com.opensymphony.xwork2.util.OgnlUtil=error
        log4j.logger.com.opensymphony.xwork2.ognl.OgnlValueStack=error

    • Anand

      Hi Jamil, followed the code setup correctly as per the attached source code, but getting the below error while clicking on the export options link.

      WARNING: Error setting expression ‘6578706f7274′ with value ‘[Ljava.lang.String;@18b32595′
      ognl.ExpressionSyntaxException: Malformed OGNL expression: 6578706f7274 [ognl.ParseException: Encountered ” “7274 “” at line 1, column 9.
      Was expecting one of:

      “,” …
      “=” …
      “?” …
      “||” …
      “or” …
      “&&” …
      “and” …
      “|” …
      “bor” …
      “^” …
      “xor” …
      “&” …
      “band” …
      “==” …
      “eq” …
      “!=” …
      “neq” …
      “” …
      “gt” …
      “=” …
      “gte” …
      “in” …
      “not” …
      “<>” …
      “shr” …
      “>>>” …
      “ushr” …
      “+” …
      “-” …
      “*” …
      “/” …
      “%” …
      “instanceof” …
      “.” …
      “(” …
      “[” …

      ]
      at ognl.Ognl.parseExpression(Ognl.java:112)
      at com.opensymphony.xwork2.ognl.OgnlUtil.compile(OgnlUtil.java:242)
      at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:214)
      at com.opensymphony.xwork2.ognl.OgnlValueStack.trySetValue(OgnlValueStack.java:187)
      at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:174)
      at com.opensymphony.xwork2.ognl.OgnlValueStack.setParameter(OgnlValueStack.java:152)
      at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:318)
      at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:230)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:238)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
      at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:544)
      at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
      at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
      at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:526)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:655)
      at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Thread.java:745)
      Caused by: ognl.ParseException: Encountered ” “7274 “” at line 1, column 9.
      Was expecting one of:

      “,” …
      “=” …
      “?” …
      “||” …
      “or” …
      “&&” …
      “and” …
      “|” …
      “bor” …
      “^” …
      “xor” …
      “&” …
      “band” …
      “==” …
      “eq” …
      “!=” …
      “neq” …
      “” …
      “gt” …
      “=” …
      “gte” …
      “in” …
      “not” …
      “<>” …
      “shr” …
      “>>>” …
      “ushr” …
      “+” …
      “-” …
      “*” …
      “/” …
      “%” …
      “instanceof” …
      “.” …
      “(” …
      “[” …

      at ognl.OgnlParser.generateParseException(OgnlParser.java:3172)
      at ognl.OgnlParser.jj_consume_token(OgnlParser.java:3051)
      at ognl.OgnlParser.topLevelExpression(OgnlParser.java:16)
      at ognl.Ognl.parseExpression(Ognl.java:110)
      … 60 more
      /– Encapsulated exception ————\
      ognl.ParseException: Encountered ” “7274 “” at line 1, column 9.
      Was expecting one of:

      “,” …
      “=” …
      “?” …
      “||” …
      “or” …
      “&&” …
      “and” …
      “|” …
      “bor” …
      “^” …
      “xor” …
      “&” …
      “band” …
      “==” …
      “eq” …
      “!=” …
      “neq” …
      “” …
      “gt” …
      “=” …
      “gte” …
      “in” …
      “not” …
      “<>” …
      “shr” …
      “>>>” …
      “ushr” …
      “+” …
      “-” …
      “*” …
      “/” …
      “%” …
      “instanceof” …
      “.” …
      “(” …
      “[” …

      at ognl.OgnlParser.generateParseException(OgnlParser.java:3172)
      at ognl.OgnlParser.jj_consume_token(OgnlParser.java:3051)
      at ognl.OgnlParser.topLevelExpression(OgnlParser.java:16)
      at ognl.Ognl.parseExpression(Ognl.java:110)
      at com.opensymphony.xwork2.ognl.OgnlUtil.compile(OgnlUtil.java:242)
      at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:214)
      at com.opensymphony.xwork2.ognl.OgnlValueStack.trySetValue(OgnlValueStack.java:187)
      at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:174)
      at com.opensymphony.xwork2.ognl.OgnlValueStack.setParameter(OgnlValueStack.java:152)
      at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:318)
      at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:230)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:238)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
      at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
      at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
      at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
      at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:544)
      at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
      at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
      at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:526)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:655)
      at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Thread.java:745)
      \————————————–/

      • http://www.simplecodestuffs.com Mohaideen Jamil

        Your data has some special character.. Display tag leads to above problem if data has special character in them ….. you can decode those data before adding into display tag list..

      • http://gravatar.com/aldhor aldhorAldhor

        (Sorry for my english) OGNL only support name’s atributes well formmed in Java and these names cannot start with numbers :(
        You cannot avoid this warning

    • suresh

      Hi Jamil I am new to struts2.0. I am using your blog to learn struts. Its really super. I am having doubt in pagination. display tag is for static datas or dynamic dats?? How to do the edit and delete operation using display tag.Manually i have deleted the row in table. after moving to the second page i m getting error.How to resolve this?? please help me..If it is possible please provide example for edit and delete operation using display tag. Thanks in Advance.

    • manjari

      HI ,

      Same i was implemented Pagination Concept in struts2.It is showing the UI-level as { [1] [2][3]…….}.
      If i am click the 2nd page…is showing the error as….

      “session was expired”.please try again…..

      please, give me the solution.

    • Ali

      Hi Jamil,

      You are doing a great job,
      Can you please upload how to export PDF using display tag.

      • http://www.simplecodestuffs.com/ Mohaideen Jamil

        Hi ,

        Currently im busy with jquery tutorials , the following link can help you on this topic.

        dzone.com/tutorials/java/struts/struts-example/struts-display-tag-example-1.html

        Let me know if have any doubts.

        • Ali

          How to use Web Services in Struts2

    • Ali

      Hi Jamil,

      You are doing a great job,
      Can you please upload how to export PDF using display tag.

      • http://www.simplecodestuffs.com/ Mohaideen Jamil

        Hi ,

        Currently im busy with jquery tutorials , the following link can help you on this topic.

        dzone.com/tutorials/java/struts/struts-example/struts-display-tag-example-1.html

        Let me know if have any doubts.

        • Ali

          How to use Web Services in Struts2

          • Ali

            Can u please upload WebServices with struts2, because i have searched in net also but , I can’t get any solutions.

          • http://www.simplecodestuffs.com Mohaideen Jamil

            Hi Ali,

            I myself still learning web services, Once i got enough knowledge, i will share the article on the same.

    • Suthagar

      Hi Jamil

      I am using display tag, tiles for pagination and export functionality in Struts 2 framework. If I click on next link in pagination, the request is hitting database every time. In export functionality also same. Please provide the solution for avoid unnecessary database hit.

    • Santosh Kola

      Hello ,
      As per my requirement I need to paging for more than 20,000 records .Can you please tell me is it possible by using above data grid with out any performance issue ?

      • http://www.simplecodestuffs.com Mohaideen Jamil

        Yes it is possible. But in the above example, when you click on each paging no, all the records will be fetched initially and then it will be displayed according to page no and page size.. you need to do some modification by extending display tags class.

        You can use jTable for pagination purpose, in which you can easily customize the no of records fetched and there wont be any performance issue even if your records increase by 1000 folds.

        Please refer this link on integrating jTable with struts 2.

        By friday I would write an article on pagination using jTable.

        For more on jTable you can visit jtable.org

    • win

      I would like to show images from database in display:table. How to write in display:column for img? Help me!

      • http://www.simplecodestuffs.com Mohaideen Jamil

        Hi Ramesh,
        Use the following code inside <display:table>

        [code]


        [/code]

    • http://gravatar.com/niraj111981 Niraj

      Hi,
      I am using display tag in my projects for pagination and I need list of records of current selected page.
      Steps used
      – Retrieve all records and set in list, which is part of form…
      – used same name for display:table
      Is any specific attribute set require for display:table tag.

    • Sharee

      Hi Jamil, can you please guide me how i can display result data in columns instead of rows.

      • http://www.simplecodestuffs.com Mohaideen Jamil

        Hi Sharee,

        U can do that logic(coverting rows to columns) in java class, and then pass the arralist to list to display tag.

        • Sharee

          Thanks for your quick response. Is there any other way like display:row.

          • http://www.simplecodestuffs.com Mohaideen Jamil

            No there are no such tags like that.

    • veeru

      its working fine for me but i want to add two columns with edit and delete hyperlinks for each record if i click edit i need to get that record data in form filelds , how to do this when i tried to do this i was getting error..

      • http://gravatar.com/jamilrehman Mohaideen Jamil

        Hi Veru,
        Use the following code;

        [code]









        Edit


        Delete


        [/code]

        • afsal

          what is pagination.action in the below code

          • http://www.simplecodestuffs.com Mohaideen Jamil

            its action class to be called for pagination, incase of the example written above, its displayStudentList. Hope you got my point

          • afsal

            Its not working for me.i couldn’t send the parameter value to the action.
            Its showing nothing after the action name in link.Usually it will show like this in link “actionName?paramName=value”
            but its showing like this “actionName?”

          • http://www.simplecodestuffs.com Mohaideen Jamil
          • afsal

            Its working now.Thanks a lot man.

      • Raichand Ray

        Hi Jamil.
        I have two pages update.jsp and delete.jsp.I want on clicking edit link update,jsp opens text boxes filled with values from that record.How to do that?I am a newbie.
        Thanks
        Raichand

    • apparna

      Hi Jamil,
      Your blog is cool.. !!

      Here my question is , the search data gets appended while we navigate form page 1 to page-N to the URL.How to avoid this?

    • Ramesh

      How do i replace image in First and Next tag …can you just help me out….

      • Jamil

        Hi Ramesh,
        Use the following code inside <display:table>

        [code]


        [/code]

    • Prafull

      Thanx Jamil,You blog helps me solve my code…

    • sami

      hi jamil….
      thanks for all your reply and this struts2 pagination,i will wait for next post.

    • sami

      hi jamil….
      i am new to struts…
      if i run this program i would got 404 error ,,y its come….

      • Jamil

        Hi Sami,
        You need to add all necessary jar mentioned in the post.
        Suppose if you add these library through java build path in eclipse, and if still it result in issue, then directly copy and paste these library in WEB-INF/lib folder, then clean and run it, it will work fine.
        Today i have uploaded the war file of this example, hope it will be helpful.

        • sami

          hi jamil..
          thanks for your reply..and i used your war file it has been running successfully…
          how to take a print of that table using struts2 ?..

          • Jamil

            ?? you mean to take printout ??

          • sami

            ya i want take print out that table using struts 2…,and do you have any example pagination using struts2 with ajax ,i tried pagination with Struts2 and ajax but i could not export a table into excel and xml,cvs…

          • Jamil

            Call this function onClick……

            <script>
            function printDivElement()
            {
            var divToPrint=document.getElementById(‘areaToPrint’);
            newWindow= window.open(“”);
            newWindow.document.write(divToPrint.outerHTML);
            newWindow.print();
            newWindow.close();
            }
            </script>

          • sami

            hi jamil…..
            thanks for your reply.,,if i am using the above script, pagination number and export option also would appear in that printout,how could i remove those number and export option while take a print out,…and do you have any sample for struts2 pagination with ajax….

          • Jamil

            Nope I have not started writing post on ajax :( , and I think there wont be such option to remove those string in printout alone.

    • aravind

      My requirement is to remove the word “export options” before the export file format.where I need to change in the displayTag:table

      • Jamil

        Hi aravind,
        Since no separate span tag available for that string,
        So we cannot remove it :(

    • neelesh

      —lhost:9080/PaginationEx/student?d-4037818-p=2&d-4037818-o=5 doesnt work,
      only —-lhost:9080/PaginationEx/student.action?d-4037818-p=2&d-4037818-o=5 works,
      Plz help

      • Jamil

        Hi Neelesh,
        iF you have older version of struts 2 library, then .action will get appended in url.

        Struts 2 have provided certain prevelge to set custom extension in url.Remove .action extension in struts2 for detailed explanation.

    • Muthu

      Very useful!…….

    • James

      This blog is amazing. I realy love it!