I have a desktop app that call a servlet through the method:
public int[] identify(String path) {
try {
URL url = new URL("http://localhost:8084/my-webapp/upload");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(conn.getOutputStream()));
out.write("path=" + path);
out.flush();
out.close();
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String response;
while ((response = in.readLine()) != null) {
int[] numbers = convertOutput(response);
s.showOutput(numbers);
return numbers;
}
in.close();
} catch (MalformedURLException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
} finally {
return null;
}
I have no jsp file. It's executed by the desktop app and it works. But now when I call my servlet I need to pass to the servlet an object that I've previously instantiated. How can i do that?