Solved

Fetching server setting xml off HTTPS POST request in Java!

Posted on 2011-09-29
6
250 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

734 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