Java/HTML/Loop Question

Hiya,
I wasn't too sure where I should post this so let me know if its in the right place.
Basically I am completing an online voting system using servlets. I have all the features working correctly except for one. I am totally dumstruck as to what I should put in the below ****** gap.
  out.println("<form name = vote action=ballotServlet method= POST>" +
                            "<TABLE border = 1 cellspacing = 3>" +
                            "<tr><th>Name</th><th>Description</th><th>Party</th><th></th></tr>");
                    ArrayList all = c.allCandidates;
                    for (int i = 0; i < all.size(); i++) {
                        Candidate value = (Candidate) all.get(i);
                        out.println("<tr><td>" + value.getName() + "</td>" +
                                "<td>" + value.getDescription() + "</td>" +
                                "<td>" + value.getParty() + "</td>" +
                                "<td><input type=radio name=vote value= ****** ></td></tr>");
                    out.println("</TABLE>" +
                            "<p><input type=submit id=submitVote value=Submit Vote>" +
                            "</BODY></HTML>");
                    out.close();Basically, I need the value from whatever is produced in that loop (the value of the radio button) but if I assign it to a value such as value.getName..it just reads it out as this String rather than the actual value. I have tried to assign it to a seperate value also but it just doesn't work.
Does anyone have any ideas?
Thanks,
welsh-diva87

I'm not sure this is something we can answer for you. It's a design decision. You seem to be asking "How can I identify which candidate was selected when the form gets posted back to the server?"
This identifier is whatever you want it to be. It should be some unique value for each candidate in your list, and something that won't cause problems when being URLEncoded. The name may work, in which case you could put value.getName() in your space. If that doesn't meet your needs, then use something else, even an arbitrary id string for each candidate.
Btw, the HTML you are generating is very wrong. Your attribute values need to have quotes around them in the response. If you're in java code you could print it like this:
out.println("<form name=\"vote\" action=\"ballotServlet\" ...{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • How to make a horizontal line in java html browser?? without hr

    I use java html browser
    I want to make a black horizontal line
    the <hr> line is not good
    for my customer it seems that there is a double spacing in this case
    I tried to write
    <td style = "BORDER-BOTTOM: 1px solid #000000"> ...
    but it does not work
    I suppose this style is not supported by the default StyleSheet
    I tried to write
    <td bgcolor="black" height=1>
    but the table has all rows with equal sizes
    therefore the real height is too big
    Please help me
    I tried to write
    <table border="1">... </table>
    even in this case I have table without any border

    Hi,
    the best way might be to use a blind table with all cells set to have a border on the bottom. The problem is that the standard Java runtime does not render such setting automatically. There is plenty of work involved to adapt it and still it then would work only in the adapted version and not the standard runtime environment.
    Anyway, you can find a working example of how to accomplish individual borders around table cells in open source application SimplyHTML at http://www.lightdev.com/dev/sh.htm
    Ulrich

  • Difference between Analyzer Java & HTML Client

    Hi,Does anyone know all the differences between Analyzer Java & HTML Client.A couple of diffence I noticed are:1. HTML Client doesn't support Linked Reporting Objects (LRO)2. HTML Client doesn't seem to support Navigate functionality in Java client.Are there any more differences ?TIA.

    http://download.oracle.com/docs/cd/E11882_01/install.112/e10876/toc.htm
    Pertains to the client installation.
    This guide describes how to complete a default installation of Oracle Database Client in a new Oracle home directory. It describes how to perform one of the following installation types:
    Instant Client: Enables you to install only the shared libraries required by Oracle Call Interface applications that use the Instant Client feature. This installation type requires much less disk space than the other Oracle Database Client installation types.
    Instant Client includes Instant Client Light. You may want to use this version of Instant Client if your applications will generate error messages in American English only. The advantage of using Instant Client Light is that it has a smaller footprint than regular Instant Client: its shared libraries, which your applications must load, are only 30–32 MB as opposed to the 216 MB that regular Instant Client uses. Hence, your applications use less memory.
    Administrator: Enables applications to connect to an Oracle database on the local system or on a remote system. It also provides tools that let you administer an Oracle database.
    Runtime: Enables applications to connect to an Oracle database on the local system or on a remote system.
    Custom: Enables you to select individual components from the list of Administrator and Runtime components.
    "

  • How convert java FOR loop into  taglib directive

    hi all,
    I have following code in my Jsp. It is working but, we dont want to use java FOR loop anymore. Instead use corresponding taglib directive.
    How can i convert this Java FOR loop into taglib implementation of FOR loop ?
                   <%
                   for(int i=0;i< arrMemberBenefit.length;i++)     {
                        pageContext.setAttribute("arrMemberBenefiti", arrMemberBenefit);
    System.out.println("PCPNAME: " + arrMemberBenefit[0].getPcpName());
    %>
                        <tr class="rowOdd">
                             <td headers="t1h1" class="first"><c:out value="${arrMemberBenefiti.member.firstName}${space}${arrMemberBenefiti.member.lastName}" /></td>
                             <td headers="t1h2" class="last"><c:out value="${arrMemberBenefiti.pcpName}" /></td>
                        </tr>
    <%}
    %>
    pl any help highly apprecialted
    pp

    Using the JSTL forEach tag:
    I have used your variable name for arrMemberBenefiti
    myself I would probably call it something like memberBenefit
    You may need to put the array into an attribute to begin with
    // just in case
    <% pageContext.setAttribute("arrMemberBenefit", arrMemberBenefit); %>
    // and the actual JSTL loop
    <c:forEach var="arrMemberBenefiti" items="${arrMemberBenefit}">
      <tr class="rowOdd">
        <td headers="t1h1" class="first"><c:out value="${arrMemberBenefiti.member.firstName}${space}${arrMemberBenefiti.member. lastName}" /></td>
        <td headers="t1h2" class="last"><c:out value="${arrMemberBenefiti.pcpName}" /></td>
      </tr>
    </c:forEach>Cheers,
    evnafets

  • Please help me.. how to rewrite the following java- for loop code in ada

    int i, j, n = 100;
    for (i = 0, j = 17; i < n; i++, j-- )
    sum += i * j + 3;

    how to rewrite the following java- for loop code in ada
    You should have a programming manual for Ada first. If you mean it the other way round, I think you subject line confused me.

  • Java html question

    Hi there,
    I have tried to find this answer in google news and web search but with no luck.
    I built a servlet to generate html for a webpage. I copy and paste text into a text box, and would like the java servlet to be able to find the end of a paragaph and generate the necessary html code to reflect the end of the paragraph - ie, </p> or 2 <br>'s.
    Else, I have to do this manually which is very time consuming. There must be a way to do it in code since forum softwares do it.
    Thanks in advance for any help.
    E.

    If you have the text in a string, you can use
    regular expressions with replaceAll() to replace
    a \n into a <br> or an empty line with </p><p>.
    text.replaceAll("^$", "</p><p>");
    text.replaceAll("\n","<br>");
    More about regular Expressions See
    http://www.regular-expressions.info/index.html

  • Java loop question - I think!

    Hello,
    I currently have the below code which opens a file, reads all the contents and prints it. I would like to modify it such that it the searches the file for a particular word e.g. "from" and when it reaches it, it inserts something after it e.g. "me". I think I need to put a nested loop somewhere in my while loop. Can some advise me please?
    Many thanks,
    Aisling.
    void modifyFile (String username)
    String record = null;
    int recCount = 0;
    try {
    FileReader fr = new FileReader("/tmp/Scripts/Script.xml");
    BufferedReader br = new BufferedReader(fr);
    record = new String();
    while ( (record = br.readLine()) != null) {
    recCount++;
    System.out.println(recCount + ": " + record);
    catch (IOException e) {
    // catch possible io errors from readLine()
    System.out.println("Uh oh, got an IOException error!");
    e.printStackTrace();
    }

    I tried the replaceall suggestion but it still does not work. I have included my effort below -
    Any ideas why it wont work?
    My understanding is that the below code reads a file line by line. As long as the line isnt null(i.e. end of file), the contents of the file should be printed and any instances of "from" should be replaced with the variable username. This is then written back to the file. Correct?
    Thanks again,
    Aisling.
    void modifyFile (String username)
    String record = null;
    int recCount = 0;
    try {
    FileReader fr = new FileReader("/tmp/Scripts/Script.xml");
    BufferedReader br = new BufferedReader(fr);
    record = new String();
    while ( (record = br.readLine()) != null) {
    recCount++;
    record.replaceAll("from", username);
    System.out.println(recCount + ": " + record);
    FileWriter fw = new FileWriter ("/tmp/Scripts/Script.xml");
    fw.write(record);
    catch (IOException e) {
    // catch possible io errors from readLine()
    System.out.println("Uh oh, got an IOException error!");
    e.printStackTrace();
    }

  • A few general java.nio.* questions

    Hi,
    I've been reading up on selectors and channels for networking programming. During my reading I came across this website, http://www.javaworld.com/javaworld/jw-09-2001/jw-0907-merlin.html
    It's kind of dated (3 years ago) but the example they provide on non-blocking I/O still compiles.
    Further in the article (http://www.javaworld.com/javaworld/jw-09-2001/jw-0907-merlin-p4.html) they mention a few "gotcha's" with using selectors. One in particular that caught my attention was "a selector can have only 63 channels registered, which is probably not a big deal."
    So only 63 channels max can be registered to a selector ? I searched around the web and the java API looking to confirm this. Does anyone know this to be true or if the max 63 registered channels was dropped before java 1.4 beta became the stable release of java 1.4? The article was written when java 1.4 was in beta.
    Lastly, do selectors weed out dropped socket connections? For example. Say I have 500 socket (TCP/IP) connections to a server of mine. Of those 500 , 100 are now closed by the client by the time the server comes around to send them data. As the server loops through the 500 connections using a selector, will there be a delay because 100 connections are dropped and the server must wait for a timeout before proceeding to send the data to the next connection or does the selector detect these 100 dropped connections and only use the 400 still connected?
    I hope this last question makes sense.
    Thanks in advance,
    Nick

    Hi,
    I've been reading up on selectors and channels for
    networking programming. During my reading I came
    across this website,
    http://www.javaworld.com/javaworld/jw-09-2001/jw-0907-m
    rlin.html
    It's kind of dated (3 years ago) but the example they
    provide on non-blocking I/O still compiles.
    Further in the article
    (http://www.javaworld.com/javaworld/jw-09-2001/jw-0907-
    erlin-p4.html) they mention a few "gotcha's" with
    using selectors. One in particular that caught my
    attention was "a selector can have only 63 channels
    registered, which is probably not a big deal."
    So only 63 channels max can be registered to a
    selector ? I searched around the web and the java API
    looking to confirm this. Does anyone know this to be
    true or if the max 63 registered channels was dropped
    before java 1.4 beta became the stable release of java
    1.4? The article was written when java 1.4 was in
    beta.I don't know if that limit of 63 is still there, but it probably makes sense to use a pool of threads each supporting a Selector if the number of connections gets that high.
    Lastly, do selectors weed out dropped socket
    connections? For example. Say I have 500 socket
    (TCP/IP) connections to a server of mine. Of those 500
    , 100 are now closed by the client by the time the
    server comes around to send them data. As the server
    loops through the 500 connections using a selector,
    will there be a delay because 100 connections are
    dropped and the server must wait for a timeout before
    proceeding to send the data to the next connection or
    does the selector detect these 100 dropped connections
    and only use the 400 still connected?closed channels are removed by the select statement. When using non-blocking IO, nothing waits anyway.
    I hope this last question makes sense.
    Thanks in advance,
    Nick

  • Infinite Loop Question - should be simple

    Ok I think I have a simple question to ask here. I am attempting to create a program that creates an infinite loop for multiples of two...
    ex: 2, 4, 8, 16, etc...
    The math behind it is simple, x^2 when x = 2. I then want the result of each equation to be squared, and infinitely.
    Here is the code Ive written so far, I think Im close, but I may be way off... any hints or clues as to my next step would be appreciated.
    public class loopytest {
       public static void main (String[] args)
       int x = x^2;
       while (x = 2)
       System.out.println("Value of x is " + x);
    }

    int x = x^2;You have to initialise "x" first.
    You should give it an actual value (e.g. 2) for this case.
    int x = 2;If you want to get the value of x from arguments. (e.g. java YouProgram 2)
    You should change this part of code similar to the follow.
    int x = args[1];But this one hasn't used the Math.pow(), you should read the API and amend it.
    while (x = 2)This one is actually assign x with value 2.
    If you want to compare an int, you should use "A == B", "A.equals(B)" for Object.

  • Bundling all java,html and even images in a jar file

    Hi All,
    When i bundle all my application .java files in a jar along with manifest i give something as,
    jar -cvf Name.jar manifest.txt *.classMy question is if i want to bundle even couple of HTML and even some images like(jpg,png..etc)..How should i do that???
    Thanks in advance.
    regards,
    Viswanadh

    Follow the instructions here:
    [http://java.sun.com/docs/books/tutorial/deployment/jar/index.html]
    Note that if you want to run the html. it must be outside of the jar, not in it.

  • Java Usage Concept Questions

    I have a java Command line running program. Which allow input/edit data of clients and store them into a Flat file. The problem is that i have to make a GUI, ( a thin web based client ) and using only HTML and Javascript.
    The next step is the db should be frontended by servlet or JSP that interact with thin client to perform the database retrievals.
    Now my concept Questions:
    1. Is it possible to communicate to a Java Program using HTML and Javascript? If so, any exampler, pointers?
    2. I was thinking of using HTML and Javascript to directly modify the Database. ( Since it is a flat file therefore nothing more than a txt file ) But isn't this side stepping the problem?
    3. If i could modify the Flat file using HTML and Javascript only. Why would i need JSP and Servlets? And if i could do it with JSP and Servlets only why would i need the think client ( HTML bit )?
    If all of above 3 are correct ( conceptialy ), what is the orginal command line java program for?
    The last question is why i think i have the concept wrong. Please i am new to web programming so feel free to point out any error.

    Hello,
    You a little off on a few things. let me explain what each is used for to give you a better idea what each i used for.
    HTML - Used to format data. Is static and can't do any File I/O and such
    Javascript - Is usaually used for client side validation and some cool effects.
    JSP - Is a scripting language that allows you to execute code on the server to create dynamic content and server side stuff like saving to a DB or a file
    Servlets - Kinda like JSP but gives you more control over a few things. Usaually used for form processing and Servlet/Applet communication
    for you application i would probably embed HTML/JavaScript for layout and validation into a JSP page for your display pages.. then build JSP pages to handle all you business logic and processing.
    --Zer0C00L                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Java card technology question

    Hi all
    Im new to the java card technology. I've downloaded and installed the java card kit and tested the demos on the virtual environment. I have the towitoko card reader, downloaded the cttwkw32.dll, but i dont know how to communicate with it.
    Can pls anyone tell me what steps should i follow in order to be able to communicate with the reader? is there any IDE for building such applications (except for the eclipse and the jcop toolbox)?
    Thanks in advance.

    javacard.framework is defined in a jar file, supplied with Java Card Development kit from here: http://java.sun.com/products/javacard/downloads/index.html
    As for
    import sim.toolkit.*;
    import sim.access.*;
    This question is already discussed here:
    http://forum.java.sun.com/thread.jspa?forumID=23&threadID=240703

  • Input thread - loop question

    Sorry for all the annoying questions. Just one more answered would be great, I know the problem in this code is my Input class only reads and sends one line to the server and as it isn't in a loop thethread terminates immediately, after one line leaving only the thread that's reading data from the server. I've tried a few loops but nothing seems to work. Can anyone point out what kind of while loop and where i can put it in.
    import java.net.*;
    import java.io.*;
    class Input extends Thread
    private PrintWriter toServer;
    private BufferedReader keyBoard;
    private Socket socket;
    public Input(Socket sock)
    socket = sock;
    public void run()
    keyBoard = new BufferedReader(
    new InputStreamReader (System.in));
    try {
    toServer = new PrintWriter(
    new OutputStreamWriter(
    socket.getOutputStream()),true);
    catch(Exception e) {
    String command ="";
    try {
    command = keyBoard.readLine();
    catch (IOException e) {
    toServer.println(command);
    }

    try
    try {
         command = keyBoard.readLine();
         while (command != null) {
               toServer.println(command);
              command = keyBoard.readLine();
    } catch (IOException e) {
         e.printSTackTrace();
    }

  • Java HTML Renderer

    Hi all,
    I wonder if any one could help me.
    I have recently decided to undertake the writing of an HTML browser for a project, I have been researching the idea and come to a pretty deadish sort of end.
    My research has taken me to various other browsers in java - Warrior, XBrowser etc. All have an HTML rendering engine create specifically for them (which I would like to do myself) however when I take a look at them, they are very in depth (to in depth - I just want HTML rendering).
    So my question is: Does anyone know of some simple renderer frameworks which I could take a peek at to get a point in the right direction or some books which would give me idea how to get started writing a renderer?
    Cheers,
    Reacz

    Thanks guys.
    I really want to give it a go on my own, it doesn't neccesarily have to be 100% perfect (in fact it doesn't even have to render them well at all).
    So, any ideas where else I could learn more about Renderers and how they are created for Java apps?
    As I said I have looked at Warrior and a couple of others and they abide by the DOM (Document Object Model) but they are very complicated, I wanted something more simple (if thats possible).
    Any books, or anything else anyone knows which may help me?
    Regards & Thanks,
    Reacz. :)

  • Apple Loops Questions

    1) Where does Logic store user-created loops that I've added to the library?
    2) What is the easiest/best way to convert a regular .aiff or .wav file into an apple loop?
    3) I'm getting a lot of artifacts when I use loops I created--even when the loop is being played back at the same tempo as the original! Is this normal? You'd think that if the original cut was 120 BPM, and I turn it into an Apple loop, and stick it into another project at 120 BPM, there should be no artifacts, right?
    4) Sometimes when I click "add to loop library" Logic won't let me select "looping" as an option. This is after I've already analyzed the cut in Apple Loops Utility. What's up with that?
    Any help, insight or guidance would be appreciated.
    Thank you!

    zgogor wrote:
    1/ apple loops folder / check them ....
    I see folders for all Apple's loops and jam packs, but nothing for my loops.
    Edit: Found them They are at:
    ~/Library/Audio/Apple Loops/User Loops
    Before I was checking the root /Library, which is why I couldn't find them.
    2/ apple loop utility application / check it ...
    I have been using it, but considering the strange behavior I'm getting (see question #3 and #4) I think I might be missing a step or doing it wrong. Right now I open an audio selection in Apple Loops Utility, fill in the tags, mess around with the transient sensitivity, then "save." So why can't I add it as a loop after that?
    3/ no of course.
    Any idea what I might be doing wrong?
    4/ add to appleloop library doesn't mean it is converted, check appleloop utilty first then add them to the Lib
    I did use the loop utility first. I mentioned that in my original post.
    Message was edited by: Zachary Conlyn
    Message was edited by: Zachary Conlyn

Maybe you are looking for

  • [HELP] How to backup and erase from computer

    Hi, my blackberry's keyboard don't work anymore. I have to return it to the shop.  But before, I have to backup, and moreover, erase personnal data from my blackberry. But, even if I try that from my computer, I have to type my password on the phone,

  • Windows 7 failing to boot after RAM upgrade

    Hi all, I don't think I'm being dense here, have looked through the forums and not found a similar problem! So I'm now worried there's something wrong with my iMac (21.5" late 2009 dual core Radeon 4670 1TB) - so thanks in advance for your thoughts..

  • I keep getting "This XML file does not appear to have any style information associated with it."

    I keep getting a message that reads "This XML file does not appear to have any style information associated with it. The document tree is shown below." when I try to view certain images with the document tree reading something like this: <Error> <Cod

  • Can't open doc and rtf files on my nokia e61i

    hi!I am new here,i have a problem with my e61i,I can not open doc and rtf files,if someone has a clue to tell me how can i fix the problem i'll be gratefull

  • Photoshop CS5 Process still working

    Hi, i've downloaded the trial of Photoshop CS5 extended, and installed it normally, but when i close the photoshop, with CTRL + Q or ALT + F4, apparently the application closes, but if i use process utility like Process Explorer, i've see that te pro