Solved

Fetching server setting xml off HTTPS POST request in Java!

Posted on 2011-09-29
6
239 Views
Last Modified: 2012-05-12
I simply want to run an https URL request in java and fetch the generated XML as a result of running this URL as I would on a b rowser.  I have already set up for the URL to run on the server but don't know how to fetch the XML file it pops out which are meant to be "server settings".  

A simple and quick way of performing this would be greatly appreciated!

regards
0
Comment
Question by:snajalm
  • 3
  • 2
6 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 36814150
Not sure exactly what you're asking, but you'd use a POST/GET and read the response in the usual way
0
 

Author Comment

by:snajalm
ID: 36814222
I just wan to read the output into an associcated XML file!  I don't know how to read the stream and put it in the client's local disk (not on the server).  Since I'm new to Java, I'm a bit confused as to how this process is handled!  Yeah, I'm talking about that simple process...
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 36814290
For URLConnection 'conn'

http://technojeeves.com/joomla/index.php/free/51-copying-streams
IOUtils.copyStream(conn.getInputStream(), new FileOutputStream("x.xml"));

Open in new window

0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 10

Expert Comment

by:gordon_vt02
ID: 36891485
Is this the scenario you're looking for?

Client connects to Server -> Server connects to other server, retrieving XML file -> Server sends XML file back to Client -> Client saves XML file to disk

If so, all you need to do is create a Servlet that connects to the external URL.  Then set the response header "content-type: attachment;filename=XXX.xml" and that should trigger the 'Save As' dialog in most browsers.  Connect to the URL from your Servlet and, instead of copying the URL's input stream to a FileOutputStream, copy it to the OutputStream of the HttpServletResponse object.  Once you close that stream, the data will be sent back to the client.
0
 

Author Closing Comment

by:snajalm
ID: 36928677
Thanks!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 36930294
:)
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now