我有以下的應用程序(比如應用1)在Tomcat其打開URL連接到另一個web應用(比如應用2)趴在端口8080 Tomcat上在我的程序中建立URL連接後,沒有得到請求/響應中的值?
String urlStr = "http://localhost:8080/myWebApp/xwiki/auth/my-auth!checkAuth.action"
URLConnection conn = url.openConnection();
/Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
StringBuffer sb = new StringBuffer();//Line1
有了上面的代碼被擊中我的servlet坐在端口8888 AuthenticationServlet
8080端口被設置在請求中的屬性XWikiAuthentication
並返回
request.setAttribute("XWikiAuthentication", "Successful");
return;
,但我沒有得到我的應用程序App1該參數XWikiAuthentication
的價值。我嘗試了兩種方法,只是在App1的第1行下方
方法1: - String line; ((line = rd.readLine())!= null){ sb.append(line); result = sb.toString(); }
Approach2: -
String Response=request.getAttribute("XWikiAuthentication");
String Response1=request().getParameter("XWikiAuthentication");
but got the value as nullthough iam expecting value as successfull
我不流汗如何在APP2應用程序App1參數XWikiAuthentication
一套價值?
更新: - 我使用Struts2的
感謝perception.Could你簡要介紹如何設置應用程序2中的響應標題? – 2011-12-16 05:57:47
感謝很多。有效。我希望我能標記出你的答案(你的和Nrj)是正確的。 – 2011-12-16 07:06:17