I need to know how to submit an HTML form and retrieve the data. I used the code from How do you programmatically fill in a form and 'POST' a web page?
C#
WebRequest req =
WebRequest.Create("http://localhost:8080/Test/views/user/index.jsp");
string postData = "email=test&password=test";
byte[] send = System.Text.Encoding.Default.GetBytes(postData);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = send.Length;
Stream sout = req.GetRequestStream ();
sout.Write (send, 0, send.Length);
sout.Flush ();
sout.Close ();
WebResponse res = req.GetResponse ();
StreamReader sr = new StreamReader (res.GetResponseStream ());
Debug.Log (sr.ReadToEnd ());
JSP index.jsp
<form action="/Test/views/user/success.jsp" action="POST">
<input type="text" id="email" name="email"> <br> <input
type="password" id="password" name="password"> <br> <input
type="submit" id="submit" name="submit" value="Submit"></form>
success.jsp
<'%
if(test.equals("test")){
out.print("true");
}
%'>
I wish to get that "true"
string but the code above only returns the HTML code.
How do I retrieve that "true"
value using C#? C# does not reside in server side so it is out of question.