Chat servlet FAQ

1.Q.Where do I need to save chatPackage.jar file?
 A.Use WEB-INF/lib directory of your web application.
 
2.Q.Where do I need to save configuration file (files)?
 A.It is up to you. You can save this file under the root directory of your servletrunner (e.g. webpages) and use a short file name when you run chat: ChatServlet?your_file_name or you can always use full path for setting your parameter. E.g. some like ChatServlet?/home/me/myfile.txt (or ChatServlet?c:\me\myfile.txt). The same is true if you are using initial parameters.
 
3.Q.Can I have more that one chat room?
 A.Yes, just create the own configuration file for the each room (they may have even equal settings, all what do you need is just different files) and run: ChatServlet?config1 , ChatServlet?config2 etc. You may use JSP for getting information about active users in your chat rooms.
 
4.Q.How to create a configuration file?
 A.It is a text file. So use any text editor you like
 
5.Q.How to make a link for the chat from my HTML page (WML page)?
 A.E.g. for HTML:
<html>
...
<a href="http://www.acme.com/servlet/ChatServlet?config_file">Let we talk</a>
...
</html>

and the same is true for WML:
<wml>
...
<a href="http://www.acme.com/servlet/ChatServlet?config_file">Let we talk</a>
...
</wml>
 
6.Q.How to embed chat into my HTML page?
 A.You can use frame or (iframe). E.g.:
<iframe name="mychatframe" src="http://www.acme.com/servlet/ChatServlet?config_file">
</iframe>
in the configuration file you must set parameter frame:
frame=mychatframe

you can have also a form on your page submitted login parameters to ChatServlet. Parameters names are:

Fields names are:
name - for user name
mail - for e-mail address
color - for foreground color
E.g.
<html>
...
<form method="post" action="http://your_host/servlet/ChatServlet?your_config">
Name:<input type="TEXT" name="name"><br>
E-mail:<input type="TEXT" name="mail"><br>
Color:<input type="TEXT" name="color"><br>
<input type="Submit" value="Login">
</form>
...
</html>

 
7.Q.Can I change the initial screen?
 A.Yes, at the first hand you can add your own logo. Create HTML (JSP) file with your initial screen. E.g.:

<center><b>Welcome to ACME's chat</b>
<p><img src="http://www.acme.com/logo.gif" alt="Logo"></center>

and add path to this file to your config:
logo=path_to_your_initial_file

At the second you can rewrite login dialog at all. Create HTML (JSP) file contains login form:
<html>
...
<form name="logform" method="post" action="http://your_host/servlet/ChatServlet?your_config">
Name:<input type="TEXT" name="name"><br>
E-mail:<input type="TEXT" name="mail"><br>
Color:<input type="TEXT" name="color"><br>
<input type="Submit" value="Login">
</form>
...
</html>
and add path to this file to your config:
init=path_to_your_initial_file
You can use of course type=hidden for fields with default values and even auto-submit login form through JavaScript:
document.logform.submit();

 
8.Q.I changed something in the configuration file. But looks like my chat still use the old value.
 A.1. Restart ChatServlet or servletrunner
2. Check out the config file path you are using as a parameter for servlet
3. Check out access rights for your configuration file (read rights must be)
 
9.Q.I want to be able to remove people from chat. How to do that?
 A.Add to your configuration file:
admin=your_login_name
When you login to chat with your_login_name you will be able to remove participants from the chat.
 
10.Q.Which version of Java servlets API must be on my WEB server?
 A.Java servlets API 2.0 and higher. So even Apache with the old Jserv is Ok.
 
11.Q.What if my Internet Service Provider (where I host my web server) does not support Java servlets?
 A.You can keep you web server on the old place and host ChatServlet with any provider supports Java servlets. Some of them even can preinstall our servlets for you. E,g. check out WantJAVA: http://www.wantjava.com
 
12.Q.What does it mean WAP/WML support for me?
 A.ChatServlet will detect client's browser and work correctly for standard browsers and WAP browsers. So for example if you run http://www.acme.com/servlet/ChatServlet?config_file from Internet Explorer and Nokia mobile you will be able to chat.
 
13.Q.How to use chat from JSP?
 A.At the first hand you may rewrite login procedures. Feel free to use JSP here. At the second you may use JSP for getting information about active users. E.g. suppose you have two chat rooms (first_room and second_room):

<%@ page language="java" import="com.jsos.chat.ChatInfoBean" %>
<jsp:useBean id="Chat" class="ChatInfoBean" scope="page" />
<%
   int first_room=Chat.getUsersCount("http://your_host/servlet/ChatServlet?first_room_config");
   int second_room=Chat.getUsersCount("http://your_host/servlet/ChatServlet?second_room_config");
%>
<br>First room: <%= first_room %> users
<br>Second room: <% =second_room %> users
<p> They are in the first_room:
<%
   Vector v=Chat.getUsersList("http://yourhost/servlet/ChatServlet?first_room_config");

   int j=0;
   while (j<v.size())
   {
      out.println("<br>User:"+v.elementAt(j)+" Email:"+v.elementAt(j+1));
      j+=2;
   }
%>
 
14.Q.What is else?
 A.Check out Coldbeans site: http://www.servletsuite.com for the latest version of ChatServlet.

 Chat servlet home page: ChatServlet

 © Coldbeans     Comments?