Re: Http Connection




"Hector" <HEPETI@xxxxxxxx> wrote in message
news:33da8795.0504051432.265fed8@xxxxxxxxxxxxxxxxxxxxx
> > Few questions.
> > 1. Can access xml file in web browser?
> > 2. Can you share code how you are reading URL....
>
> Hi everybody,
>
> 1. Yes, I can access my database because I have another code to view
> some information from it. In addition to this, I changed my code. I
> only try to read the file now (see code below).
>
> 2. Yes, I can access xml file with my browser (IE6 or Mozilla
> Firefox).
>
> 3. My code is simple, because I changed it for a basic class to test:
>
> package prueba;
> import java.net.*;
> import java.io.*;
>
> public class prueba {
> public prueba() throws Exception
> {
>
> URL url=new URL("http://www ... file.xml");
> HttpURLConnection huc=(HttpURLConnection) url.openConnection();

What are you doing here? URL.openConnection returns URLConnection.
Though this may not be causing the problem.

> InputStream is = huc.getInputStream();
>
> }
>
> }
>
> And my index.jsp ...
>

Here few more questions,

1) which is your browser? IE? If browser is IE (internet explorer) it
automatically send logged in domain, user id and password. So you won't see
actual authentication happening.

2) Which is your web server where your XML file is kept?


Below code works perfectly fine for me to fetch any document on the web!

<code>

package test;
import java.io.*;
import java.net.*;
public class HttpTester {
private String path;
public HttpTester(){
this.path="";
}

public HttpTester(String path){
this.path=path;
}

public void setPath(String path){
this.path=path;
}

public String getPath(){
return this.path;
}

public String getContent(){
String content="";
try{
URL url= new URL(this.path);
StringBuffer sb=new StringBuffer();
try{
URLConnection con=url.openConnection();
String s;
boolean shouldRead=true;
InputStream is=con.getInputStream();
BufferedReader br=new BufferedReader(new
InputStreamReader(is));

while(shouldRead){
s=br.readLine();
if(s==null){
shouldRead=false;
}else{
sb.append(s);
sb.append("\n");
}
}
content=sb.toString();
}catch(IOException ioe){
ioe.printStackTrace(System.err);
}
}catch(MalformedURLException me){

}
return content;
}

public static void main(String[] args) {
HttpTester ht=new
HttpTester("http://www.myserver.com/requiredpage/index.html";);
System.out.println(ht.getContent());
}
}

</code>


regards
Holla


.



Relevant Pages

  • Re: Access denied ( From one site to another, that is in another server)
    ... the xml file using a browser and I was be able to do through the browser, ... >>> I think you used NET classes, because of the code you sent to me, so I ... Does NET need the MSXML parser? ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • How to get browser to write a file to local disk
    ... There is a browser based application written in Flash Action Script that needs to write an XML file to the local disk. ... What should happen is a XML file is then written to disk which the application uses in several ways further downstream including applying an XSLT transformation to display the results. ... The catch is that none of these browsers allows files to be written to disk for security reasons regardless if Java applets, JavaScript, ECMAScript, etc. are used. ... So the problem is once the form is submitted and the Flash Action Script has the output XML ready, how to circumvent security and get the XML file written to preferably the same drive and directory the application was launched from. ...
    (Security-Basics)
  • Re: Not Enough Storage Error during XML transformation
    ... "Erwin Moller" ... XML file have 4000+ records. ... Or your customer with another machine, browser, OS, browserversion, etc. ... A good general solution would be to implement some sort of pagination. ...
    (comp.lang.javascript)
  • sa.windows.com
    ... warning today that my browser wanted to go to sa.windows.com. ... "HUH?" ... "Search Companion uses XML files to define both UI and some ... that XML file is available from sa.windows.com. ...
    (microsoft.public.windowsxp.basics)
  • Re: Http Connection
    ... Can access xml file in web browser? ... I can access xml file with my browser (IE6 or Mozilla ... public class prueba { ...
    (comp.lang.java.programmer)