ASP使用隐藏参数重定向到jsp而没有表单

时间:2011-03-03 05:43:21

标签: asp.net jsp post redirect

我有一个ASP页面,其中有一个链接被传递给用JSP编写的另一个域。 我需要将一个参数从ASP页面传递到JSP页面,但应该隐藏它不被用户捕获。 在JSP页面的另一侧,我将检索参数并相应地使用它。我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:0)

您可以在.NET页面中执行WebRequest到JSP页面,在服务器端JSP上设置您需要的任何内容,然后重定向到已经存在服务器端状态的JSP URL。

// Create a request for the URL.        
WebRequest request = WebRequest.Create ("http://www.contoso.com/default.html");
// If required by the server, set the credentials.
request.Credentials = CredentialCache.DefaultCredentials;
// Get the response.
HttpWebResponse response = (HttpWebResponse)request.GetResponse ();
// Display the status.
Console.WriteLine (response.StatusDescription);
// Get the stream containing content returned by the server.
Stream dataStream = response.GetResponseStream ();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader (dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd ();
// Display the content.
Console.WriteLine (responseFromServer);
// Cleanup the streams and the response.
reader.Close ();
dataStream.Close ();
response.Close ();

//redirect after