I'm trying to access an internal site project, This is the a part of the page source for the site
<form method="post" action="doDelete">
Are you sure you want to delete 'Apple?'?
<input name="Submit" value="Yes" class="submit-button" type="submit" />
</form>
I have this code
doSubmit("http://ma.some-website:8080/member/Apple/delete","Yes");
public static void doSubmit(String url, String data) throws Exception {
String content = "";
URL siteUrl = new URL(url);
HttpURLConnection conn = (HttpURLConnection) siteUrl.openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setDoInput(true);
HttpURLConnection.setFollowRedirects( true );
DataOutputStream out = new DataOutputStream(conn.getOutputStream());
content = URLEncoder.encode(data, "UTF-8");
System.out.println(content);
out.writeBytes(content);
out.flush();
out.close();
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line = "";
while((line=in.readLine())!=null) {
System.out.println(line);
}
in.close();
}
In the webpage there is a confirmation box asking if "i wish to delete this user(Apple)" how do i programmatically click that? I'm thinking i need to identify the method which is "doDelete" and pass in "Yes" parameter?