1

I am trying to create a paginated table in Struts 2 using DisplayTag and I can´t make it work.

I have created the following files:

Class's name Profesores.java:

package org.apache.struts.registro.model; 

public class Profesores { 
    private String nombre; 
    private String nacionalidad; 
    private String formacion; 
    private String aniosExperiencia; 
    private String clasesDomicilio; 
    private String clasesOnline; 
    private String correoElectronico; 
    private String correoElectronicoSeguridad; 
    private String movil; 
    private String tituloAnuncio; 
    private String descripcionAnuncio; 
    private long precio; 

    public Profesores(){ 

    } 

    public Profesores(String nombre,String nacionalidad,String tituloAnuncio){ 
        this.nombre = nombre; 
        this.nacionalidad = nacionalidad; 
        this.tituloAnuncio = tituloAnuncio; 
    } 


    public String getNombre() { 
        return nombre; 
    } 

    public void setNombre(String nombre) { 
        this.nombre = nombre; 
    } 

    public String getNacionalidad() { 
        return nacionalidad; 
    } 

    public void setNacionalidad(String nacionalidad) { 
        this.nacionalidad = nacionalidad; 
    } 

    public String getFormacion() { 
        return formacion; 
    } 

    public void setFormacion(String formacion) { 
        this.formacion = formacion; 
    } 

    public String getClasesDomicilio() { 
        return clasesDomicilio; 
    } 

    public void setClasesDomicilio(String clasesDomicilio) { 
        this.clasesDomicilio = clasesDomicilio; 
    } 

    public String getClasesOnline() { 
        return clasesOnline; 
    } 

    public void setClasesOnline(String clasesOnline) { 
        this.clasesOnline = clasesOnline; 
    } 

    public String getCorreoElectronico() { 
        return correoElectronico; 
    } 

    public void setCorreoElectronico(String correoElectronico) { 
        this.correoElectronico = correoElectronico; 
    } 

    public String getMovil() { 
        return movil; 
    } 

    public void setMovil(String movil) { 
        this.movil = movil; 
    } 

    public String getTituloAnuncio() { 
        return tituloAnuncio; 
    } 

    public void setTituloAnuncio(String tituloAnuncio) { 
        this.tituloAnuncio = tituloAnuncio; 
    } 

    public String getDescripcionAnuncio() { 
        return descripcionAnuncio; 
    } 

    public void setDescripcionAnuncio(String descripcionAnuncio) { 
        this.descripcionAnuncio = descripcionAnuncio; 
    } 

    public long getPrecio() { 
        return precio; 
    } 

    public void setPrecio(long precio) { 
        this.precio = precio; 
    } 

    public String getCorreoElectronicoSeguridad() { 
        return correoElectronicoSeguridad; 
    } 

    public void setCorreoElectronicoSeguridad(String correoElectronicoSeguridad) { 
        this.correoElectronicoSeguridad = correoElectronicoSeguridad; 
    } 

    public String getAniosExperiencia() { 
        return aniosExperiencia; 
    } 

    public void setAniosExperiencia(String aniosExperiencia) { 
        this.aniosExperiencia = aniosExperiencia; 
    } 
} 

Action's name: ProfesoresAction

package org.apache.struts.registro.action; 

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

import org.apache.struts.registro.model.Profesores; 

import com.opensymphony.xwork2.ActionSupport; 

public class ProfesoresAction extends ActionSupport{ 
private static final long serialVersionUID = 1L; 

private List <Profesores> listaAnunciosProfesores = new ArrayList<Profesores>(); 

public String execute() throws Exception { 

    listaAnunciosProfesores.add(new Profesores("Johny","1","B.Tech")); 
    listaAnunciosProfesores.add(new Profesores("Lourde","2","M.Tech")); 
    listaAnunciosProfesores.add(new Profesores("Mark Boucher","3","B.Tech")); 
    listaAnunciosProfesores.add(new Profesores("Sandy","4","B.Tech")); 
    listaAnunciosProfesores.add(new Profesores("Teena","5","MCA")); 
    listaAnunciosProfesores.add(new Profesores("Michal Bevan","6","M.Tech")); 
    listaAnunciosProfesores.add(new Profesores("Saranya","7","MCA")); 
    listaAnunciosProfesores.add(new Profesores("Rahamat","8","B.Tech")); 
    listaAnunciosProfesores.add(new Profesores("Rahul","9","M.Tech")); 
    listaAnunciosProfesores.add(new Profesores("Sugan","10","B.Tech")); 
    setListaAnunciosProfesores(listaAnunciosProfesores); 
    return SUCCESS; 
} 

public List<Profesores> getListaAnunciosProfesores() { 
    return listaAnunciosProfesores; 
} 

public void setListaAnunciosProfesores(List<Profesores> listaAnunciosProfesores) { 
    this.listaAnunciosProfesores = listaAnunciosProfesores; 
} 

} 

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> 

<constant name="struts.enable.DynamicMethodInvocation" value="false" /> 
<constant name="struts.devMode" value="true" /> 

<package name="basicstruts2" extends="struts-default"> 

<!-- If no class attribute is specified the framework will assume success and 
render the result index.jsp --> 
<!-- If no name value for the result node is specified the success value is the default --> 
<action name="index"> 
<result>/index.jsp</result> 
</action> 

<!-- If the URL is hello.action the call the execute method of class HelloWorldAction. 
If the result returned by the execute method is success render the HelloWorld.jsp --> 
<action name="hello" class="org.apache.struts.helloworld.action.HelloWorldAction" method="execute"> 
<result name="success">/HelloWorld.jsp</result> 
</action> 

<action name="register" class="org.apache.struts.registro.action.Register" method="execute"> 
<result name="success">/thankyou.jsp</result> 
<result name="input">/register.jsp</result> 
</action> 

<action name="registroProfesores" class="org.apache.struts.registro.action.RegistroProfesores" method="execute"> 
<result name="success">/thankyou.jsp</result> 
<result name="input">/registroProfesores.jsp</result> 
</action> 

<action name="listaProfesores" class="org.apache.struts.registro.action.ProfesoresAction" method="execute"> 
<result name="success">/ListaProfesores.jsp</result> 
</action> 
</package> 
</struts> 

jsp's name: ListaProfesores.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> 
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %> 
<%@ taglib prefix="s" uri="/struts-tags" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
<title>Insert title here</title> 
</head> 
<body> 
<display:table name="listaAnunciosProfesores" requestURI="listaProfesores" pagesize="2" export="false"> 
<display:column property="nombre" title="Roll" paramId="nombre" sortable="true"/> 
<display:column property="nacionalidad" title="Name" sortable="true"/> 
<display:column property="tituloAnuncio" title="Course" sortable="true" /> 
</display:table> 
</body> 
</html> 

I'm facing this error:

may 04, 2013 10:00:12 PM org.apache.jasper.compiler.TldLocationsCache tldScanJar 
INFO: Al menos un JAR, que se ha explorado buscando TLDs, aún no contenía TLDs. Activar historial de depuración para este historiador para una completa lista de los JARs que fueron explorados y de los que nos se halló TLDs. Saltarse JARs no necesarios durante la exploración puede dar lugar a una mejora de tiempo significativa en el arranque y compilación de JSP . 
may 04, 2013 10:00:12 PM org.apache.catalina.core.StandardWrapperValve invoke 
SEVERE: El Servlet.service() para el servlet [jsp] en el contexto con ruta [/Form_Validation_Struts2_Ant] lanzó la excepción [java.lang.NoClassDefFoundError: org/apache/commons/lang/UnhandledException] con causa raíz 
java.lang.ClassNotFoundException: org.apache.commons.lang.UnhandledException 
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711) 
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556) 
at java.lang.Class.getDeclaredConstructors0(Native Method) 
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source) 
at java.lang.Class.getConstructor0(Unknown Source) 
at java.lang.Class.newInstance0(Unknown Source) 
at java.lang.Class.newInstance(Unknown Source) 
at com.sun.beans.finder.InstanceFinder.instantiate(Unknown Source) 
at com.sun.beans.finder.InstanceFinder.find(Unknown Source) 
at java.beans.Introspector.findExplicitBeanInfo(Unknown Source) 
at java.beans.Introspector.<init>(Unknown Source) 
at java.beans.Introspector.getBeanInfo(Unknown Source) 
at org.apache.jasper.compiler.Generator$TagHandlerInfo.<init>(Generator.java:3943) 
at org.apache.jasper.compiler.Generator$GenerateVisitor.getTagHandlerInfo(Generator.java:2209) 
at org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1640) 
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1539) 
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376) 
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428) 
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434) 
at org.apache.jasper.compiler.Node$Root.accept(Node.java:475) 
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376) 
at org.apache.jasper.compiler.Generator.generate(Generator.java:3489) 
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:250) 
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:373) 
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353) 
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340) 
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646) 
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357) 
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) 
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) 
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:88) 
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:225) 
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) 
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) 
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) 
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) 
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927) 
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) 
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) 
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999) 
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565) 
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
at java.lang.Thread.run(Unknown Source) 

Please, could anyone help me?

3
  • So far it looks like you don't have the appropriate versions of one or more dependencies. Are you using Maven? Also, for the sanity of everyone involved, please indent your JSP and XML files. May 4, 2013 at 22:17
  • EL stands for expression language, you can't use EL expressions in the struts tags.
    – Roman C
    May 5, 2013 at 8:56
  • Thanks for your replies. I am not using Maven, I am using Ant. I have installed more dependencies, the ones from this website: displaytag.sourceforge.net/11/displaytag/dependencies.html May 5, 2013 at 12:53

1 Answer 1

1

Check if you have common-lang.jar of version 2.3 (as written by your link here: http://displaytag.sourceforge.net/11/displaytag/dependencies.html) otherwise browse if the jar has this class. If there is no class org.apache.commons.lang.UnhandledException in this jar you should download recommended version (http://commons.apache.org/proper/commons-lang/).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.