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 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 Tutorials/Questions & Answers:
Advertisements
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
Correct errors - Java BeginnersCorrect 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
Java Servlet : Http Response HeadersJava 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
XMl and Java web servicesXMl and
Java web services I want to do a project on
java web services and
XML. I wanted to ask, how the data entered by user through the HTML file... and JDBC the
response can be sent back to the client? Also, how the
XML file can
Java + XML - XMLJava + 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
java and xml - XMLjava 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
Java-XML-DOM - XMLJava-
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 java and xml - XMLjava 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 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 and xml problem - XMLjava 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 xmljava 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 xmljava 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
XML in java - XMLXML 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
Read XML in java - XMLRead
XML in java Hi Deepak, I want to read a
xml file which have only one element with multiple attributes with same tag name.
here is my file... a solution.my
java code is given below.
import java.io.File;
import
java - XML
This is my
XML file then how can read this
XML file Using DOM & SAX parsers in
java?
How can write the same data into
XML file using DOM parser?
Could you
java with xmljava with xml hi
i have a problem.
// this sample code is reading
xml file in
java
DefaultHandler handler = new DefaultHandler...
xml file change in future then my
java code will also change. but is there any
php parse soap responsephp parse soap response What is soap and how can i convert a soap
response to
XML.
Thanks in Advance
java - XMLjava How can write data into
XML file using DOM parser?
How can convert HTWL file to
XML file
java - XMLjava how can i validate my
xml file using
java code plz send me de... kumar Hi friend,
Step to validate a
xml file against a DTD (Document Type Definition) using the DOM APIs.
Here is the
xml file "User.xml
Java and converting a PDF to XMLJava and converting a PDF to XML I reviewed your example - https://www.roseindia.net/tutorial/
java/
xml/pdftoXML.html - and on many users group... getting a
response from them.Can you help me out ?? This project is very important
Java and converting a PDF to XMLJava and converting a PDF to XML I reviewed your example - https://www.roseindia.net/tutorial/
java/
xml/pdftoXML.html - and on many users group... getting a
response from them.Can you help me out ?? This project is very important
XML and javaXML and java Hi
I have
xml data in XMLStreamreader object how to retrive tha data and write into a file using
java
Your help will be much appreciated
Thanks
Hi Friend,
Try the following code:
import java.io.
java - XMLjava How to prepare an
xml document by reading data from a table in the database .
(the database access logic is written inside the servlet
java - XML you get the data3. And in the servlet class you can use the DOM api to create
xml... it to the
xml treedoc.appendChild(root);For more information please visit http://www.roseindia.net/
xml/dom/createdomchildelement.shtmlThanks
XML parsing using Java - XMLXML parsing using Java I'm trying to parse a big
XML file in
JAVA.
The goal is like i will take console input from user until "Coverage" in element "MIRate"(THE
XML code is below).once he enters coverage rate I need
java - XML in the
XML document while i am parsing the file using SAX event based parser.... provide the way in
java. Hi Friend,
Try the following code:
import... parser = parserFact.newSAXParser();
System.out.println("
XML Data
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 clonning with java and passing argumentsXML 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??>
diplay response diplay
response Sir,
How show sum of two tex boxes data to third box
Answer
(adsbygoogle = window.adsbygoogle || []).push
java - XMLjava How to read the values of XMLStreamConstants.CDATA in simple
java JAVA - XMLJAVA hi.. i want to talk to any SWT expert in
JAVA... how can i do it? Hi friend,
For read more information,Examples and Tutorials on SWT visit to :
http://www.roseindia.net/tutorials/swt/
Thanks