import java.io.IOException;
import java.io.PrintWriter;
import java.util.Properties;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class AreaCode extends HttpServlet {
private Object[][] data = new Object[][] { { "Yukon Territory", new int[] { 867 } }, };
Properties lookup = new Properties();
public void init() {
for (int i = 0; i < data.length; i++) {
Object[] record = data[i];
String state = (String) record[0];
int[] codes = (int[]) record[1];
for (int j = 0; j < codes.length; j++) {
lookup.put(String.valueOf(codes[j]), state);
}
}
}
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,
IOException {
res.setContentType("text/vnd.wap.wml");
PrintWriter out = res.getWriter();
String msg = null;
String code = req.getParameter("code");
String region = null;
if (code != null) {
region = lookup.getProperty(code);
}
out.println("");
out.println(" + "\"http://www.wapforum.org/DTD/wml_1.1.xml\">");
out.println("");
out.println("");
out.println(" ");
out.println(" Area code '" + code + "'
");
if (region != null) {
out.println(" is " + region + ".
");
} else {
out.println(" is not valid.
");
}
out.println("
");
out.println(" ");
out.println(" ");
}
}
/*
"-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
Enter an Area Code:
*/