I am writing a web application using asp.net. I connect to a JSP page through some network that is not public but available to my server side. My goal is from my asp.net page (which will be public) post data to a jsp page (which is private for users) and then retrieve the answer of the jsp.page
protected void Page_Load(object sender, EventArgs e)
{
Page page = HttpContext.Current.Handler as Page;
String Url = "https://192.168.0.1:1111/aaa/sss/test.jsp";
StringBuilder postData = new StringBuilder();
postData.Append("a=" + p.Request.Form[0] + "&");
postData.Append("b=" + p.Request.Form[1] + "&");
postData.Append("c=" + p.Request.Form[2] + "&");
postData.Append("d=" + p.Request.Form[3] + "&");
postData.Append("e=" + p.Request.Form[4] + "&");
postData.Append("f=" + p.Request.Form[5] + "&");
postData.Append("g=" + p.Request.Form[6] + "&");
postData.Append("h=" + p.Request.Form[7]);
StreamWriter writer = null;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
request.Method = "POST";
request.ContentType = "text/html";
request.ContentLength = postData.ToString().Length;
try
{
writer = new StreamWriter(request.GetRequestStream());
writer.Write(postData.ToString());
System.Web.HttpContext.Current.Response.Write(writer.ToString());
}
finally
{
if (writer != null)
writer.Close();
}
}