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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:45:20+00:00 2026-06-15T14:45:20+00:00

the process is: a list of received messages shown in a table with a

  • 0

the process is: a list of received messages shown in a table with a reply link in front of each one. pressing reply goes to this controller:

    @RequestMapping("/createMessage")
public String createMessage(@RequestParam("receiver") String receiver, HttpSession session, Model model){
  try{  

    Message message = new Message();
    //sender, Date, and receiver are known and are added to the object      

    model.addAttribute(message);

    return "newMessage";

  } catch (Exception e){
        model.addAttribute("message", "Can't create message!");
        return "error"; 
  }

newMessage.jsp is as follow. it receives the model, because from:, To:, and Date: fields are properly filled:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"   "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Send Message</title>
</head>
<body>
<form:form modelAttribute="message" method="POST" action="sendMessage">
<table border="1">
<tr>
  <th>To: </th><td>${message.userName}</td>
</tr>
<tr>
  <th>from: </th><td>${message.fromUser}</td>
</tr>
    <tr>
  <th>Date: </th><td>${message.messageDate}</td>
</tr>
<tr>
  <th>Message</th>
  <td>
    <form:textarea path="message"/>
  </td>            

</table>
<input type="submit" value="send Message">
</form:form>  

</body>
</html>

when send button is pressed the following controller is responsible to create the object in the database (using Hibernate), but it gives the error of “fromUser column can not be null”. shows that the connection to the database is working, but the object is not passed to this controller. why?

@RequestMapping("/sendMessage")
public String sendMessage(HttpSession session,@ModelAttribute("message") Message message, Model model){

    try{
    MessageDAO mDao = new MessageDAO();
    Message message2 = mDao.create(message);

    model.addAttribute("message", "Message was sent");
    return "success";

    } catch(Exception e){
        model.addAttribute("message", "Can't create message!");
        return "error";
    }


}
  • 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-15T14:45:21+00:00Added an answer on June 15, 2026 at 2:45 pm

    Debug your sendMessage routine. Your form only contains a field for the message, the other fields are technically not part of the form. Either you want to store your message object to the session so the java bean survives the two requests or you can repeat userName, fromName, etc. as hidden fields, so they are mapped to the new request bean created for sendMessage.

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

Sidebar

Related Questions

A program receives a list of Messages (base type). Each message in the list
How does one sort a list in Erlang depending on a tag for each
How do I get a process list of all running processes from Python, on
I'm trying to write a bash script that will process a list of files
Why won't XMLSerializer process my generic list? Sub Main() Serializing() End Sub <System.Serializable()> _
I want to get the list of process names for the applications which are
I implement an app with some list of process IDs. I used Runtime.getRuntime().exec(ps) to
I'm in the process of making a simple Todo List application based on Joosy
I'm in the process of creating a double-linked list, and have overloaded the operator=
I have a process where a user puts in a comma delimited list that

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.