--- android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureServlet.java 2010/06/16 09:58:15 861 +++ android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureServlet.java 2010/07/09 21:02:13 969 @@ -6,6 +6,7 @@ import java.util.logging.Logger; import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -28,6 +29,7 @@ /** * Servlet implementation class DepartureServlet */ +@WebServlet(urlPatterns={"/DepartureServlet"}) public class DepartureServlet extends HttpServlet { private static final long serialVersionUID = 1L; @@ -93,7 +95,7 @@ if (format.equalsIgnoreCase("xml")) { resp.setContentType("text/xml"); - resp.getWriter().print( formatXml(beans, stationName) ); + resp.getWriter().print( formatXml(beans, stationName, arrival) ); } else if (format.equalsIgnoreCase("html")) { String advStr = req.getParameter("advanced"); @@ -105,12 +107,12 @@ req.setAttribute("stationID", station ); getServletContext().getRequestDispatcher("/ViewDepartures.jsp").forward(req,resp); } else { - throw new ServletException("Unknown format"); + resp.sendError(400, "Unknown format"); } } - protected String formatXml(List beans, String stationName) throws ServletException{ + protected String formatXml(List beans, String stationName, boolean arrival) throws ServletException{ String xml = ""; try { DocumentBuilder builder = docBuilderFactory.newDocumentBuilder(); @@ -120,6 +122,7 @@ Document doc = impl.createDocument(null,null,null); Element root = doc.createElement("departureinfo"); root.setAttribute("station", stationName); + root.setAttribute("arrival", Boolean.toString(arrival) ); for (DepartureBean departure : beans) { Element train = doc.createElement("train");