95-702 Organizational Communications And Distributed Object Technologies Homework 2 Due Midnight on Friday, June 13, 2008 For full credit, your code will work and be well documented with well chosen variable names. Overall, it will be easy for the grader to read your code. Voting with a browser ===================== (1) 30 Points. Using Eclipse and Tomcat, write a JSP page and a servlet that uses cookies to allow a user to vote for one of three candidates but also determines if an individual has voted for president more than once. The initial page will ask the user to vote for McCain, Clinton, or Obama. After the user selects a candidate execute a servlet that writes the user's choice back to the browser and to a cookie. If the user votes a second time, from the same browser with cookies turned on, reject the new vote and tell the user who they already voted for. This is not actually secure but it allows us to explore the use of cookies. Post this project to the assignment section of blackboard. (2) 30 Points. Add a hand written shared object (singleton) to the system above and use it to collect a vote tally. A second report page should be available to a voting administrator with user name "Jethro" and password "cementpond". Anyone with this username and password will be able to collect the vote tally for each candidate at any point in time. Perform your username and password check within your servlet. (Tomcat can also be configured to do this but here we will do it ourselves.) In going from question 1 to question 2, you will need to modify the web.xml file. You may have to restart Tomcat to have the new web.xml file accepted. The modification to the web.xml file needs to be done correctly. Plenty of example web.xml files are available on the internet. Post this project to the assignment section of blackboard. Voting with a web service ========================= (3) 40 Points. Write a simple voting web service and two clients using JAX-WS 2.0. The ballot for this voting service will contain three individuals: "Clinton","Obama", and "McCain". You may assume that registered voters have been issued identification tokens. These are the integers 0,1,2,...9. There are only ten registered voters. The web service will have the following interface: // If this is a registered voter and the candidate is on the // ballot and this voter has not voted before then this // method adds 1 vote to the candidate's vote tally. // A status message is returned to the caller indicating // the success or failure of this method call. The status // string may read "Vote accepted", "No such candidate" or // "This voter has already voted once." public String vote(int voterIdentification, String candidate); // If the voting administrator's name and password are both // correct and the candidate is on the ballot, this method // returns the number of votes cast for the candidate. // The method returns a -1 if the candidate's name is not // on the ballot. It returns a -2 if the administrator's // name is not correct and returns a -3 if the password is // not correct. public int total(String candidate, String adminName, String adminPassword); Two command line clients will access this web service. The first will be called Voter.java and will run as shown: java Voter Enter voter ID: 8 Enter candidate: Obama Vote recorded java Voter Enter voter ID: 8 Enter candidate: Obama Illegal vote (you already voted) java Voter Enter voter ID: 9 Enter candidate: Clinton Vote recorded The second will be called Admin.java and will run as shown: java Admin Enter admin user name: Jethro Enter admin password: cementpond Enter candidate: Obama Votes for Obama = 2 Submit at least three Java files for this part of homework 2. One Java file will implement the web service and two Java files will implement the clients. Be sure to test your Admin client with illegal user names and passwords. Use command line shells for the web service part of this assignment. I have had trouble getting Eclipse to run the APT tool. It works fine from the DOS screen. JDK 6 for the Apple has recently come out. I have not tested JAX-WS on the Apple. It is suggested that you use a PC for this homework.