Details
-
Clarification
-
Resolution: Won't Do
-
Major
-
None
-
None
-
High
Description
It is a strange issue
MyClient Application
String data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<PreferenceXMLRequest>" +
"<ApiName>getAppComponentPreferenceGroupMapping</ApiName>" +
"<PreferenceInData>" +
"<AppCode>RL</AppCode>" +
"</PreferenceInData>" +
"</PreferenceXMLRequest>";
StringBuilder objBuilder = new StringBuilder("");
try
{
System.out.println("Input XML :\n" + data);
//URL url = new URL("http://"+ SERVER_NAME + "/preference-web-" + PreferenceServiceVersion.LOCAL_VERSION + "/preference");
URL url = new URL("http://localhost:8080/Game/Playhere?tokenid=TEST01ST");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
data = URLEncoder.encode(data, "UTF-8");
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(conn.getOutputStream()));
out.write(data);
out.flush();
out.close();
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String response;
System.out.println("\nOutput XML :");
while ((response = in.readLine()) != null)
in.close();
}
<b>Servlet : Playhere.java</b>
dopost method
InputStream in = null;
String inputXml = "";
boolean isUrnPresent = false;
try
{
String userToken = request.getParameter("tokenid");
in = request.getInputStream();
.......................
here is what is happening:
in Playhere.java, if userToken = request.getParameter("tokenid")is placed above the assignment of "in" variable (the way it is happening in the shown snippet), then request.getInputStream returns null in JBoss and tomcat. while, in WebLogic, it returns the stream.
if "in" variable is assigned the stream before the assignment of "UserToken" variable, then it works perfect!
Can anyone pls explain the issue ?