W3C home > Mailing lists > Public > www-jigsaw@w3.org > July to August 1997

A simple qn !

From: Nirmalkumar - Patil <npatil@cs.tamu.edu>
Date: Mon, 21 Jul 1997 13:28:31 -0500 (CDT)
Message-Id: <199707211828.NAA09744@dilbert.cs.tamu.edu>
To: www-jigsaw@w3.org

Hello all ,

I am in the process of learning more abt Jigsaw. I tried to have
a multiple selection box in a form as follows :

<select multiple name="favcolor" size = 3>

I used data.getMultipleValues("favcolor") to obtain the array of selected 
options .. but I get a "Document contains no data" from the browser 
when I try to run this. I have attached the code below.

An httpexception is thrown when I try to access an element
of the array that is not been allocated memory. 

I was able to work around this by catching the ArrayOutOfBoundsException and
setting a flag in the catch loop .. but there must be a better way  to do this. .. Or rather how do I extract values from a String array whose index I don't 
know ? 

Would appreciate any help here.



package w3c.jigsaw.contrib;

import java.util.*;

import w3c.jigsaw.http.*;
import w3c.jigsaw.forms.*;
import w3c.jigsaw.html.*;

import w3c.tools.store.*;
import w3c.www.http.*;
import w3c.jigsaw.resources.*;

public class MyFormResource extends PostableResource {
    String dummy = new String();

  public Reply handle(Request request, URLDecoder data) 
                throws HTTPException {

    String tmp[] = new String[20];
    HtmlGenerator g = new HtmlGenerator("myform"); // set title
    g.append("<h1>data obtained</h1>");

    tmp = data.getMultipleValues("favcolor");

    int i=0;

    while ( tmp[i] != null ) {
      System.out.println(" AFTER "+i+" :" + tmp[i]);
      g.append("<li>Testing select : ", tmp[i]);
      if( tmp[i] == (String)null )

    System.out.println("\ni is : "+i);
    Reply reply = request.makeReply(HTTP.OK);
    return reply;

  public MyFormResource() { 

Received on Monday, 21 July 1997 14:30:45 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:25:31 UTC