I am developing chat appliction using jsp and servlets. Can anyone tell me, what are the possiblities to notify the administrator (trigger events in administrator account), when the client hits the "Startchat " button?
DWR might offer a solution for use in webapp. for other solutions, you can search google for 'java' and 'comet'
Since it is a chat application can't you have the user send a message to the administrator when a client hits the Start chat button?
Just let the button fire a HTTP request to the server side which in turn invokes the Servlet
associated with the url-pattern
of the particular HTTP request. The request can be fired either synchronously with a simple link or form:
<form action="servletUrl">
<input type="submit" value="Startchat">
</form>
...or asynchronously with help of a shot of JavaScript/Ajax. jQuery is of great help here:
$('#buttonId').click(function() {
$.get('servletUrl', function() {
// Callback here.
});
});
...
<button id="buttonId">Startchat</button>
Finally in the Servlet
associated with the url-pattern
of /servletUrl
just do the desired task to notify the administrator. As you didn't tell in what way you'd like to notify the administrator (there are dozens, as Bozho stated in a comment), I'll only give a trivial kickoff example:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
notifyAdministratorAbout(request);
if (not requested by ajax) {
request.setAttribute("start", true);
request.getRequestDispatcher("chat.jsp").forward(request, response);
}
}