Home Answers Viewqa JSP-Servlet XML response correct in broser but incorrect in Java

 
 


mamba
XML response correct in broser but incorrect in Java
1 Answer(s)      9 months ago
Posted in : JSP-Servlet

Firs of all I want to say that I was able to read XML response from URL. Thank you for this and many other helps. I read and printed the response (code below) but the result is not correct.

In browser shows me (correct):

<ENELIT>
<GESI>
<RI>
<NR id="008201dfa306f4a2" tu="N" nr="0412395504" ut="" cp="" dp="" tm="" ca="" da="" rt="" cc="4"/>
</RI>
</GESI>
</ENELIT>

And in Java it prints this (incorrect):

<html>
  <head>
    <link rel=stylesheet href="/psiche/styles/IEStyle.css" type="text/css">
  </head>
  <body>

    <SCRIPT FOR=window EVENT=onload LANGUAGE="JAVAScript">
      if (top.areaApplication != undefined)
      {
        alert("Sessione utente scaduta. Effettuare il logon");
        top.areaApplication.location = "/gesi/online/root/login.htm";
      } 
    </SCRIPT>
    <h2>Sessione scaduta, Effettuare il logon.</h2> 
  </body>   
</html>

How can I get the correct result? Thank you!

My code for getting and printing the response: Example 1:

URL url = new URL("http://gesi-ro-test.banat.enelro:8010/dynamic/gesi/ri/elab/phonerequest/wind.serid=008201dfa306f4a2&nr=06648624&is=2011/04/20%2013:03:03.296&rt=RE/");
BufferedReader in = new BufferedReader(
new InputStreamReader(url.openStream()));

String inputLine;
while ((inputLine = in.readLine()) != null)
      System.out.println(inputLine);
in.close();

Example 2:

URL url = new URL("http://gesi-ro-test.banat.enelro:8010/dynamic/gesi/ri/elab/phonerequest/wind.ser?id=008201dfa306f4a2&nr=06648624&is=2011/04/20%2013:03:03.296&rt=RE");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.connect();
InputStream stream = connection.getInputStream();

BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
StringBuilder sb = new StringBuilder();
String line = null;
while((line = reader.readLine()) != null)
{
    sb.append(line).append("\n");
}
stream.close();
System.out.println(sb.toString());
View Answers

August 22, 2012 at 4:48 PM


I just saw your thread and analysed your problem you are facing. I suggest that your browser is cooperating with the server in maintaining a session, most likely by receiving and sending a cookie. Your Java code should do the same thing. So first it should go to the login page with the right parameters, and then it should receive a cookie along with the response, and then it should go to the data page, sending the cookie along with the data.









Related Pages:
XML response correct in broser but incorrect in Java
XML response correct in broser but incorrect in Java  Firs of all I want to say that I was able to read XML response from URL. Thank you...;/ENELIT> And in Java it prints this (incorrect): <html> <head>
Identify correct and incorrect statements or examples about EJB programming restrictions.
Identify correct and incorrect statements or examples about EJB... Overview Next     Identify correct and incorrect statements... rules of the Java programming language make unavailable. The enterprise bean
Identify correct and incorrect conditional expressions, BETWEEN expressions, IN expressions, LIKE expressions, and comparison expressions.
Identify correct and incorrect conditional expressions...; Identify correct and incorrect conditional expressions...;   Prev Up NextIdentify correct and incorrect statements
Identify correct and incorrect statements or examples about the client's view of exceptions received from an enterprise bean invocation.
Identify correct and incorrect statements or examples about...; Identify correct and incorrect statements or examples about the client's view... interfaces are both Java RMI interfaces, and therefore the throws clauses
Identify correct and incorrect statements about the purpose and use of the deployment descriptor elements for environment entries, EJB references, and resource manager connection factory r
Identify correct and incorrect statements about the purpose and use... correct and incorrect statements about the purpose and use of the deployment... whether a given code listing is appropriate and correct with respect
Identify correct and incorrect statements or examples about the purpose and use of EJB QL.
Identify correct and incorrect statements or examples about...;Next    Identify correct and incorrect statements...;Home Identify correct and incorrect conditional expressions, BETWEEN
Java Servlet : Http Response Headers
Java Servlet : Http Response Headers In this tutorial, you will learn how to Http Response Headers works in java servlet. Http Response Headers : Web server sends response with one or more response headers including the document
Identify correct and incorrect statements or examples about the client view of an entity bean's local component interface (EJBLocalObject).
Identify correct and incorrect statements or examples about...;   Identify correct and incorrect statements or examples about the client... correct and incorrect statements or examples about the client view
Identify correct and incorrect statements or examples about the client view of a entity bean's remote component interface (EJBObject).
Identify correct and incorrect statements or examples about...;   Identify correct and incorrect statements or examples about....     Prev Up NextIdentify correct and incorrect
Identify correct and incorrect statements or examples about the client view of a session bean's local and remote component interfaces.
Identify correct and incorrect statements or examples about the client view of a session bean's local and remote component interfaces...;   Identify correct and incorrect statements or examples about
Identify correct and incorrect statements or examples about the rules and semantics for relationship assignment and relationship updating in a CMP bean.
Identify correct and incorrect statements or examples about...; Prev Up NextIdentify correct and incorrect statements or examples... for Container-Managed Persistence (CMP) Next     Identify correct
Identify correct and incorrect statements or examples about an entity bean's primary key and object identity.
Identify correct and incorrect statements or examples about.... Entity Beans Next    Identify correct and incorrect statements or examples about an entity bean's primary key and object
Given a security-related deployment descriptor tag, identify correct and incorrect statements and code related to that tag.
correct and incorrect statements and code related to that tag. Prev ...; Given a security-related deployment descriptor tag, identify correct and incorrect statements and code related to that tag
Free Java Is it correct?
Free Java Is it correct?  Hi, Is Java free? If yes then where I can download? Thanks   Hi, You can download it from http://www.oracle.com/technetwork/java/javase/downloads/index.html Thanks
php parse soap response
php parse soap response  What is soap and how can i convert a soap response to XML. Thanks in Advance
Correct errors - Java Beginners
Correct errors  Identify and correct the errors in the following program: public java Method { public static method1(int n, m) { n += m; xMethod(3. 4); } public static int xMethod(int n) { if (n > 0) return 1
Identify correct and incorrect statements about the Application Assembler's responsibilities, including the use of deployment descriptor elements related to transactions and the identifica
Identify correct and incorrect statements about the Application Assembler's responsibilities, including the use of deployment descriptor elements...; Identify correct and incorrect statements about the Application Assembler's
Server_Gives_Null_Response
port(6066). I have one client class which is in different java project. My... for connection at port 6066. When i run my client class form different java... at port 6066. My Problem is that when i send response from server (port 6066
Produces XML file but format not correct for storing data using JSP and XML
Produces XML file but format not correct for storing data using JSP and XML  hii I have created a project using JSP and XML as database to store data entered by user in XML file ,It stores data entered in XML file
Identify correct and incorrect statements or examples about application exceptions and system exceptions in entity beans, session beans, and message-driven beans.
Identify correct and incorrect statements or examples about application exceptions and system exceptions in entity beans, session beans...;Exceptions Next    Identify correct and incorrect statements
Identify correct and incorrect statements or examples about persistent relationships, remove protocols, and about the abstract schema type of a CMP entity bean.
Identify correct and incorrect statements or examples about...; Identify correct and incorrect statements or examples about persistent... for Container-Managed Persistence (CMP) Home Identify correct and incorrect
JSP implicit object "response"
page according to the correct or incorrect login. It has two separate pages - one for incorrect login & another for correct login. response-redirect.html...;response' object , reply is sent back to the browser. It is an implicit object
Waiting for ur quick response
Waiting for ur quick response  Hi, I have two different java... to run it java A The output is: Hai This part is completed. Now i ll go... have to run it java A Now the output is: Hello Now i want to get
XML Interviews Question page29,xml Interviews Guide,xml Interviews
Response: HTTP/1.1 200 Ok Content-Type: application/rdf+xml <rdf:RDF... XML Interviews Question page29   ... of fragment identifiers for XML media types. However, HTTP does NOT transmit
Response Filter Servlet Example
Response Filter Servlet Example       This Example shows how to use of response filter in  Java Servlet. Filter reads own initial parameters and adds its value
Java Xml Data Store
or XML file. As a good Java programmer you will use correct Object-Oriented...Java Xml Data Store  I have to do this project and i'm finding it so hard its way over my head if any one has any ideas or help. What would the best
xml
xml  how to creatte html file and validate using java and finally i need get web.xml file
XML - XML
XML XSD validation in java  Can anyone help in writing validation for XML XSD in Java
Java XML parser
Java XML parser  Hi friends, i am new to java XML parsing. i need to parse the following xml response which i got from a url hit: <response> <status>SUCCESS</status> <app-config> <CHECK_LOW_SCORE>
xml - XML
xml  how to match to xml file?can you give example with java code
Access Request and Response
the request and response object in struts 2 application. To access the request... and to access the response object, use the ActionContext or implement... action class. Accessing the request and response object, you need a struts.xml
XML clonning with java and passing arguments
XML clonning with java and passing arguments  Hi, I have a XML file as follows. My requirements are as below. 1. Clone the whole xml file. 2... if 2 then with arguments1 and then arguments2. <?xml version=ΓΆβ?¬Β?1.0??>
xml - XML
xml  hi convert xml file to xml string in java ,after getting the xml string result and how to load xml string result? this my problem pls help..."); FileOutputStream output = new FileOutputStream("new.xml"); ReadXML xml = new
i need a quick response about array and string...
i need a quick response about array and string...  how can i make a dictionary type using array code in java where i will type the word then the meaning will appear..please help me..urgent
fetch database value to text box based on selected value my code given below pls correct my code
pls correct my code  my Code Given below Pls... help me send correct..., HttpServletRequest request, HttpServletResponse response... the template in the editor. */ java class package fetch
fetch database value to text box based on selected value my code given below pls correct my code
pls correct my code  my Code Given below Pls... help me send correct..., HttpServletRequest request, HttpServletResponse response... * and open the template in the editor. */ java class package fetch
java and xml - XML
java and xml  Hi Deepak, I want learn xml and java(applications). Which editor is best usefull(trial--version) in my applications...; Hi friend, http://www.roseindia.net/xml/dom/ Thanks
XML DOM error - Java Beginners
XML DOM error  import org.w3c.dom.*; import javax.xml.parsers....("xml Document Contains " + nodes.getLength() + " elements."); } else...); } } } the above program "To Count XML Element" was copied from this website (roseindia.net
Java + XML - XML
Java + XML  1) I have some XML files, read one xml... java...the attribute value..not sure now how to read the xml file passing..." pointing to a hello xml file ..read that file and get the value of the parent
getOutputStream() has already been called for this response
called for this response. here is my jsp code: <%@ page import...,com.zyom.webclient.util.MozartConstants"%> <%@ page language="java" pageEncoding... form, HttpServletRequest request, HttpServletResponse response
Java-XML-DOM - XML
Java-XML-DOM  Hi! I need some help. I have to make java program that loads an xml file and from it builds DOM(later i will have to work with it - like using xpath in java find some value and replace it...). Since i'm new to java
Writing xml file - Java Beginners
Writing xml file  Thank you for the quick response The values which... XmlServlet().createXmlTree(doc); System.out.println("Xml File Created... from xml tree StringWriter sw = new StringWriter
java and xml - XML
java and xml   test_final_1 2009-025T13:23:45 B2B I want to validate each tag.. and i don't have any xsd.. kindly help me to solve...://www.roseindia.net/xml/dom/DOMValidateDTD.shtml Thanks
XML in java - XML
XML in java  Write a program using SAX that will count the number of occurrences of each element type in an XML document and display them...://www.roseindia.net/xml/sax/SAXElementCount.shtml Hope that it will be helpful
XML with JAVA - XML
document and the processing in JAVA program . Find the time for each XML element...XML with JAVA  Hi.. This is Priya here. Thanks for responding me. I have a query. "Write program in java to evaluate the time to access
Java--Xml Modify Node Value - Java Beginners
Java--Xml Modify Node Value  I have the following xml. test... of ,,and through NodeList. I wrote the follwoing code. package xml_handson; import...)); System.out.print("Enter XML File name: "); String xmlFile = bf.readLine
java and xml problem - XML
java and xml problem  hi, i need to write a java program that generates an xml file as follows: aaa vvv --------- i have witten a program in java, but im
java with xml
java with xml  Hi i am reading xml data with sax parser in java. ok its fine. But in future xsd and xml will change. now my question is if xsd and XML will change my java progrm will not change. is it possible ? Thanks
java with xml
java with xml  Hi i am reading xml data with sax parser in java. ok its fine. But in future xsd and xml will change. now my question is if xsd and XML will change my java progrm will not change. is it possible ? Thanks

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.