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]

# 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
# 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...