Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6549899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:09:00+00:00 2026-05-25T12:09:00+00:00

JSP PAGE <%– Document : DeptListing Created on : 20-Aug-2011, 10:12:36 Author : LenasalonM01

  • 0
JSP PAGE
<%-- 
    Document   : DeptListing
    Created on : 20-Aug-2011, 10:12:36
    Author     : LenasalonM01
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Department listing</title>
    </head>
    <body>
        <%-- <jsp:include page="Header.jsp">
            <jsp:param name="header" value="Dept Listing"/>
</jsp:include>--%>
        <table>
            <logic:iterate id="dept" name="departments">
                <tr>
                    <td>
                        <bean:write name="dept" property="name" />
                    </td>
                    <td>
                        <html:link page="/listEmployees.do"
                                   paramId="deptid" paramName="dept"
                                   paramProperty="id">
                            show
                        </html:link>
                    </td>
                </tr>
            </logic:iterate>
        </table>
        <%@include file="/Footer.jsp" %>
    </body>
</html>

FORM BEAN

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hrms;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author LenasalonM01
 */
public class EmployeeForm extends org.apache.struts.action.ActionForm {

    public static final String EDIT_MODE = "edit";
    public static final String DELETE_MODE = "delete";
    public static final String ADD_MODE = "add";
    String action;
    Employee employee;

    public EmployeeForm() {
        employee = new Employee();
        action = EmployeeForm.ADD_MODE;
    }

    public Employee getEmployee() {
        return employee;
    }

    public void setEmployee(Employee employee) {
        this.employee = employee;
    }

    /**
     * Returns the action.
     * @return String
     */
    public String getAction() {
        return action;
    }

    /**
     * Sets the action.
     * @param action The action to set
     */
    public void setAction(String action) {
        this.action = action;
    }

    /**
     * @see org.apache.struts.action.ActionForm#reset(ActionMapping,
    HttpServletRequest)
     */
    /**
     *
     */
    @Override
    public void reset(ActionMapping mapping,
            HttpServletRequest request) {
        this.employee = new Employee();
        this.action = ADD_MODE;
    }

    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
    @Override
    public ActionErrors validate(ActionMapping arg0, HttpServletRequest arg1) {
        ActionErrors errors = new ActionErrors();
        if ((employee.getFirstName() == null)
                || (employee.getFirstName().length() < 3)) {
            errors.add("FirstName", new ActionMessage("error.employee.firstname"));

        }
        return errors;
    }
}

DEPARTMENT ACTION

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.hrms;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author LenasalonM01
 */
public class ListDepartmentsAction extends org.apache.struts.action.Action {

    /* forward name="success" path="" */

    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @throws java.lang.Exception
     * @return
     */
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        request.setAttribute("departments", Dept.getDepartments());
        return mapping.findForward("listing");
    }
}

STRUTS-CONFIG

<action input="/"
                name="EmployeeForm"
                path="/listEmployees"
                scope="request"
                validate="true"
                type="action.ListEmployeesAction">
            <forward name="listing" path="/EmployeeListing.jsp"/>
        </action>
        <action path="/listDepartments"
                scope="request"
                name="departments"
                validate="true"
                type="action.ListDepartmentsAction">
            <forward name="listing" path="/DeptListing.jsp"/>
        </action>
        <action path="/editEmployee" 
                type="action.EditEmployeeAction"
                name="employeeForm"
                attribute="employeeForm"
                input="/EmployeeForm.jsp"
                scope="request"
                validate="true">
            <forward name="form" path="/EmployeeForm.jsp"/>
            </action>
        <action input="/EmployeeForm.jsp"
                name="employeeForm"
                action="action.UpdateEmployeeAction"
                path="/updateEmployee"               
                scope="request"
                type="action.UpdateEmployeeAction">
                    <forward name="listing" path="/EmployeeListing.jsp"/>
                </action>
<!--         <action input="/employee_registration.jsp" name="loginform" path="/login" type="com.hrms.formlogin">
         <forward name="employee_reg" path="/register_employee.jsp"/>
         </action>-->

    </action-mappings>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:09:01+00:00Added an answer on May 25, 2026 at 12:09 pm

    What happens if you either (a) rename the form bean config (the “name” attribute in the action mapping config) or (b) rename the departments collection to something else besides the form bean name?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Code in the jsp page: <%@page contentType=text/html pageEncoding=UTF-8%> <%@taglib prefix=c uri=http://java.sun.com/jsp/jstl/core %> <%@page import=GeneralClasses.FooClass
In a JSP page, I created a <h:form enctype=multipart/form-data> with some elements: <t:inputText> ,
I am creating one jsp page in which I read in a text file,
I has a jsp page (index.jsp) with a form with two text fileds username
In jsp page directives we mentioned contentType=MIME-Type, in this MIME means what?
I have created a jsp page which run fine when executed in tomcat.But when
I have a jsp page in which rows are created dynamically to a table
In my jsp page i have one text box and two combo box. An
The jsp page named uploadTextContent.jsp contains the following code, <html:cancel value=Close accesskey=c styleClass=Button onclick=JavaScript:closeWellFormatContent('<%=request.getAttribute(message)%>')
I have a jsp page. if a user enters a certain text a ajax

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.