Hi

Try
 FileObject endObj = new FileObject("/PostingJob/end.html");

this "absolute path" begins in your servlet base directory.

Ivan




[EMAIL PROTECTED] on 12.10.99 08:32:39
Please respond to [EMAIL PROTECTED]


To: [EMAIL PROTECTED]
cc:

Subject: Re: How to open a file using Web Address ?

Hi,


    You have to use an absolute path to the file
not an url.
    Maybe You are thinking that this way the servlet
will be portable. Instead of your aproach you can
have an init parameter that describes the full path minus the filename
and i thing you can retrieve the init parameter with:

String pathtofile=getServletConfig().getInitParameter("filepath");

   If the file you are trying to open is not in the same machine than
you have to make a connection to the server and retrieve the file but i
think this will be
to slow for a servlet ( i mean the request from the client times out).


  ----- Original Message -----
  From: Hartono (Telebot)
  To: [EMAIL PROTECTED]
  Sent: Monday, October 11, 1999 3:29 PM
  Subject: How to open a file using Web Address ?


  Hi ...

  I want to open an HTML file using a servlet, so I didn't have to code
the HTML in my servlet !
  Currently I'm using the path to my C: drive like the following lines
!!

      FileObject endObj = new
FileObject("C:\\servlet\\PostingJob\\end.html");


  But when I changed the referenced like :

      FileObject endObj = new FileObject("
http://localhost:8000/servlet/PostingJob/main.html");

  The servlet cannot open the file and give me an exception ???

  any body know how to do this ??

  any help would very appreciated !!

  regards,
  Hartono sutirman



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=text/html;charset=iso-8859-1 http-equiv=Content-Type>
<META content="MSHTML 5.00.2014.210" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; </FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; You have to use an absolute path 
to the file</FONT></DIV>
<DIV><FONT face=Arial size=2>not an url.</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; Maybe You are thinking that this 
way the servlet </FONT></DIV>
<DIV><FONT face=Arial size=2>will be portable. Instead of your aproach you can 
</FONT></DIV>
<DIV><FONT face=Arial size=2>have an init parameter that describes the full 
path&nbsp;minus the filename</FONT></DIV>
<DIV><FONT face=Arial size=2>and i thing you can retrieve the init parameter 
with:</FONT><FONT color=#000000 face=courier size=1></FONT></DIV>
<DIV><FONT color=#000000 face=courier size=1></FONT>&nbsp;</DIV>
<DIV><FONT color=#000000 face=courier size=1>String 
pathtofile=getServletConfig().getInitParameter(</FONT><FONT color=#c10000 
face=courier size=1>"filepath"</FONT><FONT color=#000000 face=courier 
size=1>);</FONT></DIV>
<DIV><FONT color=#000000 face=courier size=1>&nbsp;</DIV></FONT>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp; If the file you are trying to open is 
not in the same machine than</FONT></DIV>
<DIV><FONT face=Arial size=2>you have to make a connection to the server and 
retrieve the file but i think this will be</FONT></DIV>
<DIV><FONT face=Arial size=2>to slow for a servlet ( i mean the request from the 
client times out). </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<BLOCKQUOTE 
style="BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; 
PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
  <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV 
  style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> 
  <A href="mailto:[EMAIL PROTECTED]" [EMAIL PROTECTED]>Hartono 
  (Telebot)</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>To:</B> <A 
  href="mailto:[EMAIL PROTECTED]" 
  [EMAIL PROTECTED]>[EMAIL PROTECTED]</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>Sent:</B> Monday, October 11, 1999 3:29 
  PM</DIV>
  <DIV style="FONT: 10pt arial"><B>Subject:</B> How to open a file using Web 
  Address ?</DIV>
  <DIV><BR></DIV>
  <DIV><FONT size=2></FONT><FONT color=#000000 size=2>Hi ...</FONT></DIV>
  <DIV><FONT color=#000000 size=2></FONT>&nbsp;</DIV>
  <DIV><FONT size=2>I want to open an HTML file using a servlet, so I didn't 
  have to code the HTML in my servlet !</FONT></DIV>
  <DIV><FONT size=2>Currently I'm using the path to my C: drive like the 
  following lines !!</FONT></DIV>
  <DIV><FONT size=2></FONT>&nbsp;</DIV>
  <DIV><FONT size=2>&nbsp;&nbsp;&nbsp; FileObject endObj = new 
  FileObject("C:\\servlet\\PostingJob\\end.html");<BR></FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT color=#000000 size=2>But when I changed the referenced like 
  :</FONT></DIV>
  <DIV><FONT color=#000000 size=2></FONT>&nbsp;</DIV>
  <DIV><FONT color=#000000 size=2>&nbsp;&nbsp;&nbsp; FileObject endObj = new 
  FileObject("<A 
  
href='http://localhost:8000/servlet/PostingJob/main.html"'>http://localhost:8000/servlet/PostingJob/main.html"</A>);<BR></FONT></DIV>
  <DIV><FONT color=#000000 size=2>The servlet cannot open the file and give me 
  an exception ???</FONT></DIV>
  <DIV><FONT color=#000000 size=2></FONT>&nbsp;</DIV>
  <DIV><FONT color=#000000 size=2>any body know how to do this ??</FONT></DIV>
  <DIV><FONT color=#000000 size=2></FONT>&nbsp;</DIV>
  <DIV><FONT color=#000000 size=2>any help would very appreciated 
!!</FONT></DIV>
  <DIV><FONT color=#000000 size=2></FONT>&nbsp;</DIV>
  <DIV><FONT color=#000000 size=2>regards,</FONT></DIV>
  <DIV><FONT color=#000000 size=2>Hartono sutirman</FONT></DIV>
  <DIV><FONT color=#000000 size=2></FONT>&nbsp;</DIV></BLOCKQUOTE></BODY></HTML>

Reply via email to