I am making a chat application using JSP & Servlets.I have written the code for my one-to-one chat module which is not working fine.So please have a look at this code to rectify the errors due to which i'm not getting the desired output.
This code is for sending the message to a particular user through my JSP page send121.jsp using the servlets.
This time i've used the concept of XMLHttpRequest in this code.the code for "send121.jsp" is as follows:
When the onBlur event is executed the callservlet()Function of javascript is called, through which my OnetoOneServlet .java gets the message parameter,that message parameter's value i'm storing in an ArrayList using a plain old java class namely OnetoOne.java.
the code for both the servlet & plain java class i'm providing below.
if (nickname != null && nickname.length() > 0) { OnetoOne oto = new OnetoOne(); List result = oto.getMessages(msg); req.setAttribute("message",result); getServletContext().getRequestDispatcher("/ send121.jsp").forward(req, res);
}
}//doGet() over
}
OnetoOne.java
import java.util.*;
public class OnetoOne {
public List getMessages(String message) { List msg = new ArrayList(); msg.add(message); return msg; }
private final void _mththis() { messages = new LinkedList(); messages_size = 25; }
public OnetoOne() { _mththis(); }
private String name; private List messages; private int messages_size;
}
Now the problem i'm facing is that the message is getting stored in the ArrayListbut on the JSP side i'm not able to get it printed in the TextArea provided nor i'm able to get it on the server console for verifying purpose.
So if you could help me sort out the where the problem lies in my code I will be grateful to you.