HttpsUrlConnection - Facing problem while reading the input stream and establishing the cookie
sambasiva kumar
Greenhorn
Joined: Jan 16, 2007
Posts: 24
posted
0
Please find below the error that I am getting while reading the input stream.
The value of cookie in the process request is ............... null
java.io.EOFException at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2155)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2621)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:734)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:251)
at com.orbitreasury.fixedincome.presentation.util.AppServCommunication.receiveRequest(AppServCommunication.java:227)
at com.orbitreasury.fixedincome.presentation.util.AppServCommunication.processRequest(AppServCommunication.java:166)
at com.orbitreasury.fixedincome.control.ServerResets.main(ServerResets.java:62)
Please find the code that I am using.
-------------------------------------------------------------------------------------------------------------------------------
public synchronized PageWrapper processRequest(PageWrapper pWrapper) {
Console.println("inside processRequest urlCurrentPage = "+FISConstants.urlCurrentPage);
if(FISConstants.urlCurrentPage == null) {
Console.println("url is null application is running");
// This Condition will be true if it is run as a application
try {
// Uncomment below 2 lines to run it as a application
// NavigationController aNavController = NavigationController.getInstance();
// pWrapper = aNavController.onEvent(pWrapper);
} catch (Exception e ) {
e.printStackTrace();
}
return pWrapper;
}
if(!connectServlet()) {
pWrapper.setStatus(false);
pWrapper.setErrorMessage("Could not connect to servlet");
return pWrapper;
}
sendRequest(pWrapper);
if(cookie == null) cookie = readCookie(connection);
System.out.println("The value of cookie in the process request is ............... "+ cookie);
return receiveRequest();
}
private boolean sendRequest(PageWrapper pWrapper) {
ObjectOutputStream out = null;
try {
connection.setDoInput(true);
connection.setDoOutput(true);
System.out.println("Inside sendRequest");
out = new ObjectOutputStream(connection.getOutputStream());
out.writeObject(pWrapper);
out.flush();
}
catch (Exception e) {
e.printStackTrace();
return false; //return false in case of Exception
}
finally {
try {
if(out != null)
out.close();
} catch(Exception e) {
Console.println("Unable to close Connection"+e);
}
}
return true;
}
private PageWrapper receiveRequest() {
PageWrapper pWrapper = null;
ObjectInputStream in = null;
try {
System.out.println("Inside receiveRequest");
in = new ObjectInputStream(connection.getInputStream());
System.out.println("The Object Input Stream is .............." + in);
pWrapper = (PageWrapper)in.readObject();
System.out.println("The page wrapper Object is .............." + pWrapper);
Please find the code that I am using.
-------------------------------------------------------------------------------------------------------------------------------
Somebody please help me to resolve this issue.
Thanks in advance.
sambasiva kumar
Greenhorn
Joined: Jan 16, 2007
Posts: 24
posted
0
Please find below the code that I am using to establish the cookie.
And you can see in the log the cookie is not getting established.
-------------------------------------------------------------------------------------------------------------------------
The value of cookie in the process request is ............... null
java.io.EOFException at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2155)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2621)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:734)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:251)
at com.orbitreasury.fixedincome.presentation.util.AppServCommunication.receiveRequest(AppServCommunication.java:227)
at com.orbitreasury.fixedincome.presentation.util.AppServCommunication.processRequest(AppServCommunication.java:166)
at com.orbitreasury.fixedincome.control.ServerResets.main(ServerResets.java:62)
-------------------------------------------------------------------------------------------------------------------------
Please advice me on how to establish the cookie?
Thanks in advance.
The exception is thrown from the ObjectInputStream's constructor, which indicates that the required meta-data bytes are missing. Apparently the other side of the connection does not use an ObjectOutputStream for writing when you receive this exception. Are you sure that this connection is coming from your application, and not something else?
sambasiva kumar
Greenhorn
Joined: Jan 16, 2007
Posts: 24
posted
0
Please find below the code that I am using to write as well as read the InputStream.