Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Online voting !

Hi there i am a final year student and i was thinking of creating an internet voting system for uni student using JSP, servelets and javabeans. Really need tips on how i could go about building the system. I would really appreciate any help i get. Thanks :)
[257 byte] By [bondito] at [2007-11-11 7:13:39]
# 1 Re: Online voting !
Hello to you!

Well you may use SJS Java 8.01 as your server and after that all you have to do is to
create a few entity beans and servlets (or/and JSP).
You can "read" with the servlets from your HTML form (form for voting) and give the
information to the entity bean who stores them in a database for furter use.

NetBeans can help you to do that!!!

If you want much more detail tell me and I'll send you some code samples!!!Also
you must be a little more exact of what you want.

Have a nice day...
AnghelLeonard at 2007-11-11 22:39:03 >
# 2 Re: Online voting !
Hello to you!

Well you may use SJS Java 8.01 as your server and after that all you have to do is to
create a few entity beans and servlets (or/and JSP).
You can "read" with the servlets from your HTML form (form for voting) and give the
information to the entity bean who stores them in a database for furter use.

NetBeans can help you to do that!!!

If you want much more detail tell me and I'll send you some code samples!!!Also
you must be a little more exact of what you want.

Have a nice day...

Hi there
Thanks for the information you gave me. I am planning to build a secure Internet voting system for my university's student union, i wanted to make the system able to process votes for candidates and display the results in some graphical form. The main security issue that has to be addressed is a method of preventing individuals from voting more than once for one candidate. I was planning on creating sections for voters, candidates and adminstrators. I would really appreciate it if you could give me more ideas on how i could go about building my system, any code samples you can send me will be highly appreciated. Thank you. Email: chibuzor2001@yahoo.com
bondito at 2007-11-11 22:39:57 >
# 3 Re: Online voting !
Hello,
I will give you some samples but please wait until Monday.

Have a great weekend...
AnghelLeonard at 2007-11-11 22:41:01 >
# 4 Re: Online voting !
Hello,
I will give you some samples but please wait until Monday.

Have a great weekend...

It would be good if you specified which Monday you are talking about. ;)
aniseed at 2007-11-11 22:42:06 >
# 5 Re: Online voting !
Hello,
I will give you some samples but please wait until Monday.

Have a great weekend...

Thanks alot i really appreciate your help. Hope to receive the info from you on monday.
bondito at 2007-11-11 22:43:05 >
# 6 Re: Online voting !
Hello, I am talking about this Monday...

Here are the basic source file that you need for your application. You must
add your code and than compile,deploy and run the app.
The web page will be an .jsp (this code just link the entity bean - you must add the html tags) that let you read the information and store them to
a database created by the following script:

drop table vot;

create table vot
(id varchar(3), constraint pk_police primary key,
name varchar(25));

exit;

Now the .jsp:

<%@ page import="VOTING.LocalVoting, VOTING.VotingHome, javax.ejb.*,java.math.*, javax.naming.*, javax.rmi.PortableRemoteObject, java.rmi.RemoteException" %>
<%!
private LocalVoting LV = null;

public void jspInit() {
try {
InitialContext ic = new InitialContext();
Object objRef = ic.lookup("java:comp/env/ejb/TheVoting");
VotingHome home = (VotingHome)PortableRemoteObject.narrow(objRef, VotingHome.class);
} catch (RemoteException ex) {
System.out.println("Couldn't create converter bean."+ ex.getMessage());
} catch (CreateException ex) {
System.out.println("Couldn't create converter bean."+ ex.getMessage());
} catch (NamingException ex) {
System.out.println("Unable to lookup home: "+ "TheVoting "+ ex.getMessage());
}
}

public void jspDestroy() {
LV = null;
}
%>
<html>
//put your html tags here
//from here you may call the method from the LocalVoting interface
</html>

And the entity bean:

LocalVoting.java

package VOTING;

import javax.ejb.EJBObject;
import java.rmi.RemoteException;

public interface LocalVoting extends EJBObject{
//put here your methods and implement them in the VotingBean
}

VotingHome.java

package VOTING;

import java.util.Collection;
import java.rmi.RemoteException;
import javax.ejb.*;

public interface VotingHome extends EJBHome{

public LocalVoting create(String id,String name)throws RemoteException,CreateException;
public LocalVoting findByPrimaryKey(String id)throws FinderException,RemoteException;
}

VotingBean.java

package VOTING;

import java.sql.*;
import javax.sql.*;
import javax.ejb.*;
import javax.naming.*;
import java.util.*;

public abstract class VotingBean implements EntityBean{

private EntityContext context;

//the SQL for this methods are settle in the deploytool in EJB QL format
public abstract void setID(String id);
public abstract void setName(String name);

//ejbCreate method
public String ejbCreate(String id,String name)throws CreateException
{
setID(id);
setName(name);

return null;
}

//ejbPostCreate method
public void ejbPostCreate(String id,String nume)throws CreateException{}

//setEntityContext method
public void setEntityContext(EntityContext context)
{
this.context=context;
}

//ejbActivate method
public void ejbActivate(){}

//ejbPassivate method
public void ejbPassivate(){}

public void ejbStore(){}

//ejbLoad method
public void ejbLoad(){}

//metoda unsetEntityContext
public void unsetEntityContext()
{
context=null;
}

//ejbRemove method
public void ejbRemove(){}
}

I hope this is ok...more information in J2EE tutorial...
AnghelLeonard at 2007-11-11 22:43:58 >
# 7 Re: Online voting !
Hi thanks for the information, really appreciate, please do u have an idea on how i can prevent voters from voting more than once for a single candidate.I also need to find a way of making sure that a voter is eligible to vote, like identity checks. Thanks
bondito at 2007-11-11 22:45:07 >
# 8 Re: Online voting !
Try to register the user in a database and verify him when he try to vote (ask him for a password and e-mail address).
You must understand that what you want is possible only if the user is a "good man".
Take a look to all voting online system. Per example to the VMA there are users that
vote all night the same person. He just create a new account every time.
Anyway a good idea is to follow the usual way ask a password and a e-mail.
If a user is already in your database verify if he vote before and for who.
The HTML form (or JSP etc.) must suply a checkbox system in such a manner that only one canditate can be selected.
I hope this help...
OctaviaAndreea at 2007-11-11 22:46:10 >