package hotspotfinder;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import java.net.*;
public class MyHotspots extends HttpServlet
{
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
/*response.setContentType("text/xml");
PrintWriter out = response.getWriter();
out.println("hi- b4 try");
//System.out.println("hello");
//String XML = "" + "servlet" + "";
//out.println(XML);
*/
try
{
response.setContentType("text/xml");
PrintWriter out = response.getWriter();
//out.println("hi");
int i;
String address = request.getParameter("loc");
String[] result = address.split(",");
//out.println(result[0]);
//out.println(result[1]);
String property = request.getParameter("type");
//out.println(property);
//String[] result = null;
//String result0="Scottsdale";
//String result1="AZ";
//String property = "fedex";
int type = 0;
//String state = result[1].toUpperCase();
//out.println(state);
if(property.equals("starbucks"))
type = 0;
else
type = 1;
//String[] city = result[0].split(" ");
//out.println(city[0]);
//out.println(city[1]);
HotspotFinderLocator locator = new HotspotFinderLocator();
HotspotFinderSoap port = locator.getHotspotFinderSoap();
ArrayOfHotspot arrOfProperty = port.getHotspots(result[0], result[1], type);
Property listOfProperties[] = arrOfProperty.getProperty();
//out.println(listOfProperties.length);
String XML = "";
//XML = "";
XML = XML + "";
XML = XML + "" + property + " " + "Hotspots in" + " " + result[0] + "," + result[1] + "";
XML = XML + "";
for(i=0;i";
String p_name,p_addr,p_phn;
p_name = (listOfProperties[i].getName());
p_addr = (listOfProperties[i].getAddress());
p_phn = (listOfProperties[i].getPhone());
p_name = p_name.replaceAll("&","&");
p_addr = p_addr.replaceAll("&","&");
//out.println(p_name);
//out.println(p_addr);
//out.println(p_phn);
XML = XML + "";
XML = XML + p_name;
XML = XML + "";
XML = XML + "";
XML = XML + p_addr;
XML = XML + "";
XML = XML + "";
XML = XML + p_phn;
XML = XML + "";
XML = XML + "";
}
XML = XML + "";
XML = XML + "";
out.println(XML);
}
catch(MalformedURLException e)
{
//Handling exceptions, set the response status code to 404, and then
//use this to differentiate the repsonse at client.
e.printStackTrace();
response.setStatus(404);
}
catch(IOException e)
{
e.printStackTrace();
response.setStatus(404);
}
catch(Exception e)
{
e.printStackTrace();
response.setStatus(404);
}
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
doPost(request, response);
}
}