akademie.de
 home/aufg/kap2/Votingtool.jsp

Votingtool.jsp lookandfeel.jsp javatest.jsp

Votingtool

JSP 0
PHP 0
ASP 0
ColdFusion 0

löschen

{}


 Source

01 <%include file="_pages.jspf"%>
02 <%include file="/template/head.jspf"%>
03 <%page import="java.util.Properties" %>
04 <% 
05   if (request.getParameter("delete")!=null) {
06     application.removeAttribute("votings");
07   }
08   String[] langs=new String[] {"JSP","PHP","ASP","ColdFusion"};
09   Properties votings;
10   Object obj=application.getAttribute("votings";
11   if (obj==null) {
12     votings=new Properties();
13     application.setAttribute("votings",votings);
14   else {
15     votings=(Propertiesobj;
16   }
17   
18   String choice=request.getParameter("choice");
19   if (choice!=null && !choice.equals("")) {
20     int current=0;
21     try {
22       current=Integer.parseInt(votings.getProperty(choice));
23     catch (NumberFormatException ne) {
24       // do nothing for current is 0
25     }
26     votings.setProperty(choice,(current+1)+"");
27   }
28 %>
29 <h1>Votingtool</h1>
30 <table>
31 <%
32   int max=0;
33   int[] values=new int[langs.length]
34   for (int i=0;i<langs.length;i++) {
35     String voteAsString=votings.getProperty(langs[i]);
36     if (voteAsString!=null) {
37       try {
38         values[i]=Integer.parseInt(voteAsString);
39         max=Math.max(values[i],max);
40       catch (NumberFormatException ne){
41         values[i]=0;
42       }
43     else {
44       values[i]=0;
45     }
46   }
47   for (int i=0;i<langs.length;i++) {
48   int percent=0;
49     if (max!=0) {
50     percent=values[i]*100/max;
51     }  
52 %>
53   <tr>
54     <td><a href="<%=request.getRequestURI()+"?choice="+langs[i] %>"><%=langs[i%></a></td>
55     <td><img src="gfx/blue.gif" width="<%= percent%>" height="5" alt="" border="0"></td>
56     <td><%= values[i%></td>
57   </tr>
58 <%%>  
59 </table>
60 <br>
61 <a href="<%=request.getRequestURI()+"?delete"%>">l?schen</a>
62 <br>
63 <br>
64 
65 
66 
67 
68 <%=votings %>
69 <%include file="/template/tail.jspf"%>



<%include file="_pages.jspf"%>
<%include file="/template/head.jspf"%>
<%page import="java.util.Properties" %>
<% 
  if (request.getParameter("delete")!=null) {
    application.removeAttribute("votings");
  }
  String[] langs=new String[] {"JSP","PHP","ASP","ColdFusion"};
  Properties votings;
  Object obj=application.getAttribute("votings";
  if (obj==null) {
    votings=new Properties();
    application.setAttribute("votings",votings);
  else {
    votings=(Propertiesobj;
  }
  
  String choice=request.getParameter("choice");
  if (choice!=null && !choice.equals("")) {
    int current=0;
    try {
      current=Integer.parseInt(votings.getProperty(choice));
    catch (NumberFormatException ne) {
      // do nothing for current is 0
    }
    votings.setProperty(choice,(current+1)+"");
  }
%>
<h1>Votingtool</h1>
<table>
<%
  int max=0;
  int[] values=new int[langs.length]
  for (int i=0;i<langs.length;i++) {
    String voteAsString=votings.getProperty(langs[i]);
    if (voteAsString!=null) {
      try {
        values[i]=Integer.parseInt(voteAsString);
        max=Math.max(values[i],max);
      catch (NumberFormatException ne){
        values[i]=0;
      }
    else {
      values[i]=0;
    }
  }
  for (int i=0;i<langs.length;i++) {
  int percent=0;
    if (max!=0) {
    percent=values[i]*100/max;
    }  
%>
  <tr>
    <td><a href="<%=request.getRequestURI()+"?choice="+langs[i] %>"><%=langs[i%></a></td>
    <td><img src="gfx/blue.gif" width="<%= percent%>" height="5" alt="" border="0"></td>
    <td><%= values[i%></td>
  </tr>
<%%>  
</table>
<br>
<a href="<%=request.getRequestURI()+"?delete"%>">l?schen</a>
<br>
<br>




<%=votings %>
<%include file="/template/tail.jspf"%>