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 7817141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:08:02+00:00 2026-06-02T06:08:02+00:00

Below is the code which i want to get the output of the names

  • 0

Below is the code which i want to get the output of the names of the particular administrator number , administrator Emailid , but insted of that i am getting the output as : List of —> com.demo.model.Administrator@91e143 with different numbers , basically i am new to java .Would you please help me in the Loop Iteration .

package com.demo.action;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

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;
import org.apache.struts.actions.DispatchAction;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.demo.model.Administrator;

import com.demo.model.AdministratorDAO;
import com.demo.model.AdministratorDemo;
import com.demo.model.JQueryDataTableParam;
import com.demo.model.JqueryDatatablesParamUtil;

public class AdministratorAction extends Action {

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        System.out.println("in execute..");
        JQueryDataTableParam param = JqueryDatatablesParamUtil
                .getParam(request);


        String txt2=request.getParameter("txt1");
        //String select2=request.getParameter("select1");
        //request.setAttribute("e", "select2");

        //String select3=request.getParameter("select2");

        //System.out.println("txtValue->"+e);
        //System.out.println("txtValue->"+select2);
        System.out.println("txtValue->"+txt2);
        //String var = Administrator.isValidname(sData);
        String sEcho = param.sEcho;
        int iTotalRecords;
        int iTotalDisplayRecords;
        int start = param.iDisplayStart;
        System.out.println("start" + start);
        int last = param.iDisplayLength +param.iDisplayStart;
        System.out.println("last" + last);
        int sortColumnIndex = param.iSortColumnIndex;
        System.out.println("sortColumnIndex" + sortColumnIndex);
        String sortDirection = param.sSortDirection;
        System.out.println("sortDirection" + sortDirection);

        JSONArray data = new JSONArray();
        iTotalRecords = AdministratorDemo.getAdminCount();
        List<Administrator> Administrators = new LinkedList<Administrator>();
        for (Administrator a : AdministratorDemo.getAdimistrators()) {
            if (a.getAdministrator_nm() != null
                    && a.getAdministrator_nm().toLowerCase()
                            .contains(param.sSearch.toLowerCase())

                    || a.getAdmin_Email_ID() != null
                    && a.getAdmin_Email_ID().toLowerCase()
                            .contains(param.sSearch.toLowerCase())
                    || a.getAdmin_Fax_Phone_Num_Tx() != null
                    && a.getAdmin_Fax_Phone_Num_Tx().toLowerCase()
                            .contains(param.sSearch.toLowerCase())) {
                Administrators.add(a);

            }

        }
        iTotalDisplayRecords = iTotalRecords;

    if (Administrators.size() < param.iDisplayStart + param.iDisplayLength)

                Administrators = Administrators.subList(param.iDisplayLength,
                        Administrators.size());
            else
                Administrators = Administrators.subList(param.iDisplayStart,
                        param.iDisplayStart + param.iDisplayLength);

        System.out.println("End of the operations");

        try {
            JSONObject jsonresponse = new JSONObject();
            jsonresponse.put("sEcho", sEcho);
            jsonresponse.put("iTotalRecords", iTotalRecords);
            jsonresponse.put("iTotalDisplayRecords", iTotalDisplayRecords);
            JSONArray row = new JSONArray();

            for(Iterator<Administrator> i = AdministratorDemo.getAdimistrators().iterator();i.hasNext();)
            {
            System.out.println(i.next());
            }
            jsonresponse.put("aaData", data);
            response.setContentType("application/json");
            response.getWriter().print(jsonresponse.toString());
        } catch (JSONException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
            response.setContentType("text/html");
            response.getWriter().print(e1.getMessage());
        }


        System.out.println("In execute method.");


        return null;

    }

    public String getXMLObject(HttpServletRequest request) {

        return new java.util.Date().toString()
                + " sent by vasu from Date Action";

    }
}
  • 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-06-02T06:08:04+00:00Added an answer on June 2, 2026 at 6:08 am

    You’re making a list of Administrators, where you want to make a list of Strings.
    Alternatively (and probably better), if you can change the Administrator class, just implement the toString method in it, that will return the string you want to see on the screen.

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

Sidebar

Related Questions

I have the following code below which works, but I want to insert values
I want to know is below code correct ? I have following code which
Currently i'm using below code which works well. $(#topperAtBaseLevel:visible, #lowerAtBaseLevel:visible, #midAtBaseLevel).hide(); any optimised code?
I have below code which overrides equals() and hashcode() methods. public boolean equals(Object obj)
Can anyone help me to rewrite the below code which use a fade effect
Which code snippet will give better performance? The below code segments were written in
Below is the code which I wrote to display a tooltip content. As the
I have the code below which I use clone() and live() . The code
I have the code below which I use clone() and delegate() . The code
Hi All below is the code which i use. <!DOCTYPE html PUBLIC -//W3C//DTD XHTML

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.