get file out of server 
July 4th, 2009, 10:23 AM
| | Newbie | | Join Date: May 2009
Posts: 16
| | |
Hallo to everyone
I have an question
Is there any way to load client-side a page out of the server domain ?
(Maybe with java applet ? or any other language ?)
Thanks in advance
| 
July 5th, 2009, 07:29 AM
| | Newbie | | Join Date: May 2007 Location: Perth, Western Australia
Posts: 10
| | | re: get file out of server
Depends on what you mean by 'load'.
Are you wanting to load and execute code from the server, within the context of the active document, or simply load an entirely new page?
Clarification is needed.
| 
July 6th, 2009, 07:29 AM
| | Administrator | | Join Date: Sep 2006
Posts: 12,084
| | | re: get file out of server
Google for "file servlet". It's been done so many times before.
| 
July 6th, 2009, 09:53 AM
| | Newbie | | Join Date: May 2009
Posts: 16
| | | re: get file out of server
thanks for replying
i mean load a "something.htm" page from another dns.
| 
July 6th, 2009, 09:58 AM
| | Newbie | | Join Date: May 2009
Posts: 16
| | | re: get file out of server
to make it simpler.
lets say my server is www.server.com
I'd like to load clientside a "www.another.com/something.htm",
preferably not using www.server.com to pass it thru.
| 
July 6th, 2009, 10:56 AM
|  | Expert | | Join Date: Mar 2007
Posts: 10,634
Provided Answers: 2 | | | re: get file out of server Quote:
Originally Posted by garbmail10 to make it simpler.
lets say my server is www.server.com
I'd like to load clientside a "www.another.com/something.htm",
preferably not using www.server.com to pass it thru. | To get a file from "www.another.com/something.htm" you simply fetch the file through a URLConnection; something like this: -
import java.io.BufferedReader;
-
import java.io.InputStreamReader;
-
import java.net.HttpURLConnection;
-
import java.net.URL;
-
-
public class URLContent {
-
-
private void process(String s) {
-
-
System.out.println(s);
-
}
-
-
public URLContent(String site) {
-
-
try {
-
URL url= new URL(site);
-
-
HttpURLConnection con= (HttpURLConnection) url.openConnection();
-
-
con.setRequestMethod("GET");
-
con.connect();
-
-
if (con.getResponseCode() == HttpURLConnection.HTTP_OK) {
-
BufferedReader r= new BufferedReader(new InputStreamReader(con.getInputStream()));
-
for (String s; (s= r.readLine()) != null; )
-
process(s);
-
}
-
}
-
catch (Exception e) { e.printStackTrace(); }
-
}
-
-
public static void main(String[] args) {
-
new URLContent("http://www.another.com/something.htm");
-
}
-
}
-
kind regards,
Jos
| 
July 6th, 2009, 01:10 PM
| | Newbie | | Join Date: May 2009
Posts: 16
| | | re: get file out of server
thank you very much all.
| 
July 7th, 2009, 07:04 AM
| | Newbie | | Join Date: May 2009
Posts: 16
| | | re: get file out of server
JosAH, i have one question
may the above be used as part of an applet running on a browser ??
will the browser allow an out of server page to be fetched ??
thanks again...
| 
July 7th, 2009, 07:32 AM
|  | Expert | | Join Date: Mar 2007
Posts: 10,634
Provided Answers: 2 | | | re: get file out of server Quote:
Originally Posted by garbmail10 JosAH, i have one question
may the above be used as part of an applet running on a browser ??
will the browser allow an out of server page to be fetched ??
thanks again... | All the normal rules apply to applets when/if you use that code so you can't fetch or connect to an out of server url; you have to sign your applet for that so that it's trusted. I did that once but forgot all about it because it was a bit of a messy process. Sun has some tutorials about that subject though; google for them.
kind regards,
Jos
| 
July 7th, 2009, 08:21 AM
| | Newbie | | Join Date: May 2009
Posts: 16
| | | re: get file out of server
thanks again JosAH
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,662 network members.
|