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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:29:55+00:00 2026-06-11T19:29:55+00:00

I’m trying to build an array by fetching data from mysql. The array include

  • 0

I’m trying to build an array by fetching data from mysql. The array include text and pictures. So far everything went good but now I have no idea how to display these picture from the memolist on the JSP page. All I can see are just bunch of bytes. Let’s see:

My DBQueries looks like this:

public static ArrayList<Memo> selectAllMemoList()
{
    DBConnectionPool pool = DBConnectionPool.getInstance();
    Connection connection = pool.getConnection();
    PreparedStatement ps = null;
    ResultSet rs = null;

    String query = "SELECT Users.picture, Users.username, Messages.subject, Messages.date, Messages.msg_id " +
            "FROM Messages, Users " +
            "WHERE Messages.uid_fk = Users.uid " +
            "ORDER BY date DESC";
    try
    {
      ps = connection.prepareStatement(query);
      rs = ps.executeQuery();

      ArrayList<Memo> memolist = new ArrayList<Memo>(); 

      String dbSqlTimestamp = "";

      while (rs.next()) {
         m.setUserpicture(rs.getString("picture"));
         m.setUsername(rs.getString("username"));
         m.setSubject(rs.getString("subject"));
         m.setDate(dbSqlTimestamp = new SimpleDateFormat("dd-MM-yy HH:mm").format(rs.getTimestamp("date")));
         m.setMessageid(rs.getInt("msg_id"));
         memolist.add(m);
      }

        return memolist;
    }
    catch (SQLException e){
        e.printStackTrace();
        return null;
    }        
    finally
    {
        DBUtil.closeResultSet(rs);
        DBUtil.closePreparedStatement(ps);
        pool.freeConnection(connection);
    }
}

My MemoShowAll looks like this:

@Override
protected void doPost(HttpServletRequest request, 
          HttpServletResponse response)
          throws ServletException, IOException 
{   

    HttpSession session = request.getSession(); 

    ArrayList<Memo> memolist = DBQueries.selectAllMemoList();

    request.setAttribute("listmemo", memolist);

    String url = "/restricted/MemoList.jsp";

    // forward the request and response to the view
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);
    dispatcher.forward(request, response); 

}

MemoList.jsp

<z:rows>
    <core:forEach var="each" items="${listmemo}">
    <z:row>
        <img src="${each.userpicture}" border=0 >
        <z:label value="${each.username}"/>
        <z:label value="${each.subject}"/>
        <z:label value="${each.date}"/>
    </z:row>
    </core:forEach>
</z:rows>

Cheers,
BB

  • 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-11T19:29:56+00:00Added an answer on June 11, 2026 at 7:29 pm

    The way that i bypass this issue is by using a servlet to expose the image to the client. For this to work, you should store the image bytes retrieved from the database to the user’s session object.

    In the html i have < img src="/imageRender?id=someimageid"/ >

    Therefore when the browser will try to render the image, it will make a call to /imageRender where my servlet listens to. And the servlet will read the input parameter and then render the image from the session object based on the parameter.

    Some helpful links are:

    1) Display servlet as img src using session attribute

    2) Writing image to servlet response with best performance

    Pay special attention to link 2 @BalusC answer to the place where it says In the ImageDAO#find() you can use ResultSet#getBinaryStream() to get the image as an InputStream from the database.

    In your case you can create a List of DAO objects that will represent each row from db.

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.