<%@ page import="java.io.*" %> Ønskjeliste <% String mywish = request.getParameter("mywish"); String tittel = request.getParameter("tittel"); String finnehos = request.getParameter("finnehos"); boolean remove = false; boolean hasremoved = false; boolean donothing = false; int myind = -5; if ( mywish != null ) { myind = Integer.parseInt( mywish )*4; if ( (tittel.compareTo("fjerne") == 0 ) && (finnehos.length() == 0) ) { remove = true; } if ( tittel.length() == 0 ) { donothing = true; } } BufferedReader input = new BufferedReader(new FileReader("/locals/web/folk/jorgenav/onskeliste.txt")); String line = ""; String[] lines = new String[200]; int counter = 0; while ((line = input.readLine()) != null) { lines[counter] = line; counter++; if (remove && counter-4 == 4*Integer.parseInt(mywish) ) { counter -= 4; lines[counter+2] = ""; lines[counter+3] = ""; remove = false; hasremoved = true; } } out.flush(); input.close(); %> <% if ( mywish != null ) { if (myind == -4) { myind = counter; counter = counter + 4; } if (!hasremoved && !donothing) { lines[myind] = tittel; lines[myind+1] = finnehos; lines[myind+2] = "Ledig"; lines[myind+3] = " "; } //always give the path from root. This way it almost always works. try { PrintWriter pw = new PrintWriter(new FileOutputStream("/locals/web/folk/jorgenav/onskeliste.txt")); for (int i=0; i <%-- background: #F7E7C7 --%>
Test?

Ønskeliste til Ingvild og Jørgen sitt bryllup

Her kan me redigere ønska våre. Velg nytt ønskje eller endre eit ønskje. For å slette, endre eit ønskje og lat felta stå blanke :)

<% if (request.getParameter("mychoice") != null && request.getParameter("mychoice").compareTo("-2") != 0 ) { %> <% } %>
<% int imychoice = Integer.parseInt( request.getParameter("mychoice") ); if (imychoice >=0) { String myvalue = lines[ imychoice*4]; out.println(myvalue); } %> <% if (imychoice >=0) { int currstat = lines[ imychoice*4+1 ].compareTo("Opptatt"); if (mywish != null) { if (currstat != 0) { %> Ledig Opptatt <% } else { %> Ledig Opptatt <% } } else { %> <% } } else { %> <%= imychoice %> <% } %>
% align = "middle" > <% for( int i=0; i <% for( int j=0; j<2; j++) { %> <% } %> <% } %>
Forslag: Er å finne hos:
<%= lines[i*4+j] %>