Announcement Announcement Module
No announcement yet.
How can I show this information? (Struts + JSP) Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How can I show this information? (Struts + JSP)

    Hi all!

    Finally I could fix the problems that I had with my web application. There was a library problem!!

    Now I'm working about how get more information of my tables, I mean... I have a table called "Alumnos" and I would like to do a search by names, by surnames, etc... basically, I want to do search by string and not by ID.

    I have implemented this function in my AlumnoDao (Interface) and AlumnoDaoHibernate and it works great because I have been debugging my application and I see that I get the values from the table but the problem is the following... how can I show this information on a web page?

    I have done a JSP file where I request all the information wich I want to search (name, surname, etc..). Later I do an accion that is related with this JSP file... (in this moment the functions that I have programmed before are working okay and they give me de information) but later I don't know how can I show the information of the database in another JSP file...

    This is my JSP file where I request the information:

    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <%@taglib uri="" prefix="c" %>
    <%@taglib uri="" prefix="form" %>
    <%@taglib prefix="s" uri="/struts-tags" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>Buscar Alumno </title>
            <h1>Busqueda de Alumno </h1>
            <s:form method="post" action="busca">
                            <td><s:textfield key=""/></td>
                            <td><s:textfield key="alumno.nombre"/></td>
                            <td><s:textfield key="alumno.apellido"/></td>
                            <td colspan="2"><s:submit value="Search Student"/></td>
    This is my struts.xml:

        <package name="default" namespace="/" extends="struts-default">
        <package name="alumno" namespace="/alumno" extends="default">
            <action name="lista" class="alumnoAction" method="lista">
            <action name="edita" class="alumnoAction" method="edita">
            <action name="nuevo" class="alumnoAction" method="nuevo">
                <result name="input">/WEB-INF/jsp/alumno/nuevoAl.jsp</result>
                <result name="success" type="redirectAction">lista</result>
            <action name="guarda" class="alumnoAction" method="guarda">
                <result name="input">/WEB-INF/jsp/alumno/edita.jsp</result>
                <result name="success" type="redirectAction">lista</result>
            <action name="busca" class="alumnoAction" method="busca">
                <result name="input">/WEB-INF/jsp/alumno/buscaAl.jsp</result>
                <result name="success" type="redirectAction">Should I put a new JSP here?</result>
    And these are my AlumnoAction and AlumnoDaoHibernate:

    public class AlumnoAction extends ActionSupport {
        private static final Log log = LogFactory.getLog(AlumnoAction.class);
        private AlumnoDao alumnoDao;
        private List<Alumno> alumnos;
        private Long id;
        private Alumno alumno;
        public String lista() {
            log.debug("Lista de alumnos desde struts");
            alumnos = alumnoDao.lista();
            return SUCCESS;
        public String busca(){
            log.debug("Lista de alumnos desde struts utilizando busqueda opcional");
            alumnos = alumnoDao.listaPersonalizada(alumno.getId(), alumno.getNombre(), alumno.getApellido());
            return SUCCESS;
    ....MORE CODE...
        public List<Alumno> listaPersonalizada(Long id, String nombre, String apellido)
             String consulta2 = "FROM Alumno a WHERE like '%"+ id +"%' and a.nombre like '%"+nombre+"%' and a.apellido like '%" + apellido + "'%'";
            return hibernateTemplate.find(consulta2);

    I think I have to do a new JSP file using the information that I get after call to the search but I don't know how can I recover the information in a new JSP file when the accion busca() is completed.

    Thanks for all and sorry for my english...