Vote servlet 1.6

It is a Java servlet allows you to quickly build and deploy surveys and polls on your web site. Servlet supports WAP/WML so you may use it for your mobile users too.

You can use your own HTML (WML) stuff for survey's design and deploy servlet only as a script lets you save/review results. Or you can generate survey with this servlet without any knowledge about HTML or WML.

How to use it:

a) copy votePackage.jar into your WEB-INF/lib directory.

b) define servlet in your web.xml file:


c) define a mapping for Vote servlet


For each your poll you must provide a configuration file describes how to save messages as well as various interface settings. You can use VoteServlet in two forms.

a) pass configuration file as a parameter. E.g.:


b) define your configuration file as an initial parameter for servlet (parameter name is config):


and use servlet in this form: http://your_host/servlet/VoteServlet

A. You are using your own design for survey.

Just set this servlet as an action for your form:

<form name="VoteForm" method="post" action="http://your_host/servlet/VoteServlet?voteconf">
<input type=radio name="option1" value="like">I like it !<br>
<input type=radio name="option1" value="dislike">I hate it !<br>
<input type=submit value="Vote">


Configuration file is a text file, each line describes one parameter in the form of


Empty lines and any line starts with # or // are ignored. Current version supports the following list of parameters:

# log file. File for poll results
# This parameter is mandatory

# after vote page. This page will be displayed when user submits vote.
# By default current vote results will be outputted.

# or for WAP:

# Use cookies for preventing second time vote.
# Default value is 0 (do not use cookies).
# Otherwise you may set time in seconds when new vote
# will be prohibited. E.g. (24 hours time):

So, you have two forms for servlet usage:

Submit vote: http://host/servlet/VoteServlet?config=conf_file&act=vote
(or simply: http://host/servlet/VoteServlet?conf_file)


Show results: http://host/servlet/VoteServlet?config=conf_file&act=log

If you are using initial parameters than just skip config parameter:

Submit vote: http://host/servlet/VoteServlet?act=vote
(or simply: http://host/servlet/VoteServlet)


Show results: http://host/servlet/VoteServlet?act=log

B. You can generate survey with this servlet

Set some additional parameters in your config file and use

(or http://host/servlet/VoteServlet?act=view if configuration file described as an initial parameter).

for creating you survey

Additional parameters for config file are:

# background color (by default is white - #FFFFFF)

# foreground color (by default is black - #000000)

# font size. By default is current browser's font

# font face. By default is current browser's font

# vote colors. Color for bar chart (by default is red #FF0000)

# title (Default value is Coldbeans vote)
title=My Survey

# options (this is mandatory for generated surveys)
# List of options separated by commas.
options=My option1,My Option2,MyOption3

# Page orientation. Describes how to display options - in the one column
# (default value is 1) or in the one row (in case of column=0)

Log file format

It is a text file with comma separated values. Each line contains: IP address, date, option value

JSP integration

In JSP pages you may use special custom tags for viewing results of your polls. See Vote taglib for more details.


1. Configuration file can be saved anywhere on your server. E.g. if you are using VoteServlet?config line we assume this file is saved under the root (docBase) directory of your servletrunner. But you can of course always use the full path  for setting config file location: VoteServlet?/home/users/my_file (or VoteServlet?c:\users\my_file)

2. Some WAP gateways do not support cookies.

3. For WAP/WML options will be always outputted in the one column.

4. Log file could be saved anywhere on your server. Just use the full path. E.g.: log=c:/mydata/votes/log1.txt

5. If after value starts with http than request will be redirected to that site. Otherwise servlet assumes a local resource and forwards request.

6. Evaluation version supports up to 20 votes.

Buy this component

    For downloading:   votePackage.jar
    Sample of configuration file:  voteconf

 © Coldbeans Software     Comments?

See also JSOS - the largest collection of servlets and filters.