views:

394

answers:

2

This is the servlet code in java ME.

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    PrintWriter out = response.getWriter();

    ArrayList<String> listName = new ArrayList<String>();
    ArrayList<Integer> listLongitude = new ArrayList<Integer>();
    ArrayList<Integer> listLatitude = new ArrayList<Integer>();

    String sLongitude = (String) request.getParameter("x");
    String sLatitude = (String) request.getParameter("y");
    String path, list, scount;
    Integer numLong = null;
    Integer numLati = null;
    Connection con = null;
    String slanje = "";
    int limitLeft, limitRight, limitUp, limitDown, icount = 0;

    if (sLongitude != null && sLatitude != null) {
        try {
            numLong = Integer.valueOf(sLongitude);
            numLati = Integer.valueOf(sLatitude);
        } catch(Exception ex) {}
    }

    try{
        Class.forName("org.apache.derby.jdbc.ClientDriver");
        con = DriverManager.getConnection("jdbc:derby://localhost:1527/bazaprojekt", "projekt2009", "midlet");
        limitLeft = numLong - 8;
        limitRight = numLong + 8;
        limitUp = numLati + 8;

        ...

How do I send x and y to servlet and receive some string in Android?

+2  A: 

Just pass them as request parameters in the query string after the Servlet's URL:

http://example.com/context/servlet?x=123&amp;y=456.

BalusC
+1  A: 

If you're using the PostMethod you can set them using PostMethod.addParameter.

Pandalover