Java Beans, JSP and Access 2003 problem

Posted on 2008-11-06
Last Modified: 2013-12-29
I have problem with Access 2003 and Servlets

I have two beans:

MessageListBean and Message Bean;

A PageHandler class and a JSP page.

There are records in the tables message and actor and on the Single message page where I get just specific message record it works fine (SELECT * FROM message WHERE messageId=1).
When I try to get all records from the message table and to list them on the JSP page, nothing is returned.
No error messages.
public class MessageListBean {


    private ArrayList messages;


    /** Creates a new instance of MessageListBean */

    public MessageListBean() {

        messages = new ArrayList();

        i = 0;


    public void addMessage (MessageBean message) {



    public ArrayList getMessages() {

        return messages;



public class MessageBean {


    private String messageDate, subject, body, username, messageId, userImage;


    /** Creates a new instance of MessageBean */

    public MessageBean() {


        body= "";



        messageDate = "";

        userImage = "";


    public String getMessageDate()


        return messageDate;


    public String getSubject()


        return subject;


    public String getBody()


        return body;


    public String getUsername()


        return username;


     public String getUserImage()


        return userImage;


    public String getMessageId()


        return messageId;


    public void setMessageDate(String mDate) throws Exception


        Date d = new SimpleDateFormat("yyyy-MM-dd").parse(mDate);

        messageDate = new SimpleDateFormat("dd-MM-yyyy").format(d);



    public void setSubject(String subject)


        this.subject = subject;


    public void setBody(String body)


        this.body = body;


    public void setUsername(String username)


        this.username = username;


     public void setUserImage(String userImage)


        this.userImage = userImage;


    public void setMessageId(String messageId)


        this.messageId = messageId;



PageHandler class - processRequest method

 protected void processRequest(HttpServletRequest request, HttpServletResponse response)

    throws ServletException, IOException {    



        HttpSession mySession=request.getSession(true);

        //Validate if user is trying to avoid login


            MessageListBean MessageListBean = new MessageListBean();

            String order = request.getParameter("order");

            String orderText="ORDER BY messageDate DESC";

            if(order==null || order.trim().length()<1){

                orderText="ORDER BY messageDate DESC";


            else {

               int o = new Integer(order).intValue();


                    case 1: orderText="ORDER BY messageDate DESC";break;

                    case 2: orderText="ORDER BY messageDate ASC";break;

                    case 3: orderText="ORDER BY message.username DESC";break;

                    case 4: orderText="ORDER BY message.username ASC";break;

                    case 5: orderText="ORDER BY subject DESC";break;

                    case 6: orderText="ORDER BY subject ASC";break;



            ServletContext context = getServletContext();

            String appDirRoot = context.getRealPath("/");

            String connString = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)}; DBQ=" + appDirRoot + "forumDB.mdb";


            Connection connForum = DriverManager.getConnection(connString);

            Statement stmtMessages = connForum.createStatement();

            String sqlMessages = "SELECT * FROM message, actor WHERE message.username=actor.username " + orderText;

            ResultSet rsMessages = stmtMessages.executeQuery(sqlMessages);

           MessageBean message;

           int i=0;

            while (



               message = new MessageBean();





                message.setMessageId("" + rsMessages.getInt("messageId") );











          catch (Exception e)


             response.sendRedirect("default.jsp?message=Exception in MessageListGenerator");



JSP page:

 <c:forEach items="${MessageListBean.messages}" var="message">


          <td colspan="3"></td>

          <td width="7%">


          <c:when test="${message.userImage!=null}">

            <img src="images/${message.userImage}" border="0" width="59" height="59">



            <img src="images/default.gif" border="0" width="59" height="59"> 




          <td colspan="3"><c:out value="${message.username}"/></td>

          <td colspan="2"><c:out value="${message.subject}"/></td>

          <td colspan="2" align="center"><a href="ViewMessage?messageId=${message.messageId}">View</a></td>



Open in new window

Question by:bdimitry
    LVL 86

    Expert Comment

    >>response.sendRedirect("default.jsp?message=Exception in MessageListGenerator");

    The above is incorrect btw (urls can't contain spaces)

    You should really log an error and *then* do a redirect

    Check server logs for errors you might have missed

    Accepted Solution

    I forgot to include a call in the JSP page  to the JSTL jar files.
    Now it's working.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Java MSI Solution 3 53
    java constructor error 8 66
    sumDigits  challenge 7 41
    Exception after setting jdbc session management 2 18
    This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
    Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
    Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
    Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now