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

  • Home
  • SEARCH
  • 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 7998935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:21:21+00:00 2026-06-04T15:21:21+00:00

This Servlet, I do GROUP BY on color car. Inserted into the request and

  • 0

This Servlet, I do GROUP BY on color car. Inserted into the request and advertise in jsp
but it does not convert.

    Query query = session.createQuery("select count(carColor), carColor from Cars group by carColor order by carColor");
    List<Cars> list = query.list();
    Iterator iter = list.iterator();
    while (iter.hasNext()) {
        Object[] obj = (Object[]) iter.next();
        System.out.println(obj[0] + "  " + obj[1]);

    }

    request.setAttribute("list", list); 

    RequestDispatcher rd = request.getRequestDispatcher("test.jsp");
    rd.forward(request, response);

Console:
2 White
10 Black
5 Blue

JSP:
[[Ljava.lang.Object;@1f3b536, [Ljava.lang.Object;@fdffb1,]]

  • 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-04T15:21:23+00:00Added an answer on June 4, 2026 at 3:21 pm

    Your code really makes no sense:

    List<Cars> list = query.list();
    

    In the above line, you declare that your list is a list of Cars (which it is not)

    Iterator iter = list.iterator();
    while (iter.hasNext()) {
        Object[] obj = (Object[]) iter.next();
    

    Then you iterate on the list, and cast each element to Object[]. How could a Cars instance ever be an Object[]? The list should be declared as List<Object[]>, and you shouldn’t use raw types. Your loop should be written as

    Iterator<Object[]> iter = list.iterator();
    while (iter.hasNext()) {
        Object[] obj = iter.next();
    

    Or, even simpler:

    for (Object[] obj : list) {
    

    Now, in the JSP, I suspect you’re just using ${list} to display the list. This simply calls the toString() method on the list, which itself calls the toString() method of each element. Since each element is an Object[], the result string is [Ljava.lang.Object;@1f3b536, which means “array of Object with hashCode 1f3b536”.

    To display the elements of the list, you should iterate over the list, as you must do it in the Java code:

    <c:forEach var="array" items="${list}">
        Count: ${array[0]} - Color: <c:out value="${array[1]}"/> <br/>
    </c:forEach>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I added Comet servlet into Spring web application. This servlet does not differ from
jsp file which contains username & password which is processed at LoginServlet...this servlet does
This is a follow on to my previous question: JSP / servlet / IE
With this code i am able to render a image from a servlet ,But
This [servlet or jsp] must return an XML document [for future processing by my
Is this the correct way to set parameters upon a servlet request (tags, tagmode,
I have this servlet: public class SaveImage extends HttpServlet { protected void doGet(HttpServletRequest request,
I found this artifact pom in the maven 2 central repository: http://search.maven.org/remotecontent?filepath=javax/servlet/jsp/jsp-api/2.1.2/jsp-api-2.1.2.pom It includes:
I posted this on GAE for Java group, but I hope to get some
I have tested this servlet and it works well, except in Google Chrome it

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.