×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Blank Struts page after submit

Blank Struts page after submit

Blank Struts page after submit

(OP)
Hi !

I am learning to work with struts, after i click on submit button (in a form) i get a blank page. This thing is annoying me because i can't find the solution for a week !

The page has 2 hmtl list option. The first list loads info about a company compartiments, and after hitting "Refresh Employees", the second list should shouw data about all the employees from the selected department.

What is happening ? After hitting "Refresh Employees" i get a blank selectAngajat.do page. If i go Back and Refresh(F5) the second list option shows all the employees from that department.

Does anyone have any idea about this ? I posted some code down:

PersonalBody.jsp

CODE

<%@ page import="databeans.*"%>
<%@ page import="java.sql.Connection"%>
<jsp:useBean id="ss_PersSelected" class="databeans.CompartPersSelectedBean" scope="session"/>
<html:form action="/selectAngajat.do">
<table width="600" border="1">
<tr>
<td width="174">Selectati un Compartiment:</td>
<td width="213">
<html:select property="compartid">
<%
Connection conn=Utilitati.getConexiune();
java.util.ArrayList listaCompartimente=
    ObiectPersistent.getObjects(Compartimente.class,conn,null);
conn.close();
for(int i=0;i<listaCompartimente.size();i++) {
%>
<html:option value="<%=((Compartimente)listaCompartimente.get(i)).getCompartid()%>">
<%=((Compartimente)listaCompartimente.get(i)).getNumecompart()%>
</html:option>
<%}%> <%-- s-a inchis for-ul--%>
</html:select>

</td>
<td width="191">
<input type="submit" name="Submit" value="Refresh Employees">
</td>
</tr>
<tr>
<td width="174">Selectati Angajatul:</td>
<td width="213">
<html:select property="marcaselectata">
<% Connection conn=Utilitati.getConexiune();
if (ss_PersSelected.getCompartid() != null) //exista un compartiment selectat
{ java.util.ArrayList listaAngajati =
    ObiectPersistent.getObjects(Personal.class,conn,
" where compartid='"+ss_PersSelected.getCompartid()+"' ");
conn.close();
for(int i=0;i<listaAngajati.size();i++){%>
<html:option value="<%=((Personal)listaAngajati.get(i)).getMarca().toString()%>">
<%=((Personal)listaAngajati.get(i)).getNumepren()%>
</html:option>
<%}}%> <%-- inchidem FOR si IF --%>
</html:select>
</td>
<td width=" 191 ">
<input type="submit" name="Submit2" value="Show Employee">
</td>
</tr>
</table>

</html:form>

<%if (request.getSession().getAttribute("ss_DatePers") != null){%>
<tiles:insert page="/tiles/bodys/DateAngajatBody.jsp"/> <%}
    else if (ss_PersSelected.getCompartid() != null){%>
    <html:form action="/dateAngajat.do">
<html:hidden property="actiune" value="newObject"/>
<html:submit property="add" value="Angajat Nou" />
</html:form>
<%}%>

struts-config.xml

CODE

<struts-config>

<form-beans>
    <form-bean name="loginBean" type="databeans.LoginExistingUserForm"/>
        <form-bean name="ss_PersSelected" type="databeans.CompartPersSelectedBean"/>
 <form-bean name="ss_DatePers" type="databeans.Personal"/>
</form-beans>

<action-mappings>
<action path="/selectAngajat" type="formactions.SelectAngajatAction" name="ss_PersSelected" input="/tiles/bodys/PersonalBody.jsp" scope="session">
<forward name="succes" path="/pages/DatePersonal.jsp" redirect="true"/>
</action>
</action-mappings>
</struts-config>

SelectAngajatAction.class

CODE

package formactions;

import databeans.CompartPersSelectedBean;

import databeans.ObiectPersistent;
import databeans.Personal;
import databeans.Utilitati;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class SelectAngajatAction extends Action {

    public ActionForward perform(ActionMapping mapping, ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response) throws IOException,
                                                                      ServletException {
        CompartPersSelectedBean formBean = (CompartPersSelectedBean)form;
        java.sql.Connection conn = null;

        if (formBean.getMarcaselectata() != null &&
            formBean.getMarcaselectata().intValue() != -1)
            try { // incarc in sesiune obiectul Personal corespunzator marcii selectate de utilizator
                conn = Utilitati.getConexiune();
                Personal objPersCurent =
                    (Personal)ObiectPersistent.getObjects(Personal.class, conn,
                                                          "where marca=" +
                                                          formBean.getMarcaselectata().toString()).get(0);
                // ATENTIE! Identificatorul atributului trebuie sl fie cel definit in Struts-Contig.xml
                request.getSession().setAttribute("ss_DatePers",
                                                  objPersCurent);


                conn.close();

            } catch (Exception e) {
                e.printStackTrace();
                if (conn != null)
                    try {
                        conn.close();
                    } catch (Exception err) {
                    err.printStackTrace();
                    }
                return mapping.findForward("eroareBD");
            }
        else // daca marca e null elimin eventualul atribut ss_DatePers anterior
            request.getSession().removeAttribute("ss_DatePers");

        return mapping.findForward("success");
    }
}

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close