Whilst we are taking about URL's I thought I would sneak in this question
which has been bugging me lately in a servlet....

How do you modify the code below to pass a password and username in cases
where the URL is protected?

I can't find any examples in the documentation....

Thanks,

Andy

----- Original Message -----
From: Gokul Singh <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 26, 2000 6:03 AM
Subject: Re: FileNotFoundError in servlet


> Hi,
>
> You can not use a URL in the constructor of FileInputStream. For opening a
> connection you will have to use the URL object.
> Try this code in place of your code.
>
> /* FileInputStream fistr = new
>  FileInputStream("hostname:8080/examples/servlets/filename");
>  DataInputStream in = new DataInputStream(fistr);*/
>
> URL source = new URL("hostname:8080/examples/servlets/filename");
> DataInputStream in  = new DataInputStream( source.openStream() );
>
> I hope this works.
>
> Regds,
> Gokul
>
>
> ----- Original Message -----
> From: "Syed Mahmoods" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, July 26, 2000 3:32 AM
> Subject: FileNotFoundError in servlet
>
>
> > I have just installed the jsdk2.1.  So all the file structures are
> standard
> > to jsdk2.1, and I am new to servlets.
> > My servlet is in the /home/username/jsdk2.1/examples/WEB-INF/servlets/
> > directory.  I am trying to read a text file  and I get the IOException:
> > java.io.FileNotFoundException: hostname:8080/examples/servlets/filename.
> > I need to read this input file and then post the data to a cgi script.
> > How do I specify the path so I am able to read the file?
> >
> > Here is part of the code:
> >
> > String newLine = System.getProperty("line.separator");
> > FileInputStream fistr = new
> > FileInputStream("hostname:8080/examples/servlets/filename");
> > DataInputStream in = new DataInputStream(fistr);
> > String aLine;
> >  while ((aLine = in.readLine()) != null)
> >  {
> >    postString=postString+newLine+aLine;
> >  }
> >
> > Thanks for all the help.
> >
> >
>
___________________________________________________________________________
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > Resources: http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> >
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to