Actually, the code I was looking for was the part where I get the file
that is passed to the servlet...
The query string would look something like this:

http://localhost:8080/servletname?pg=/pages/page.html

Where the server root may be c:\www\myweb

So I would want the pg variable to be equal to:
c:\www\myweb\pages\page.html

I did accomplish this with this line of code:
out.println(readTemplate(getServletContext().getRealPath("/" + pg)));

The ReadTemplate function actually reads in the file and passes it
back... If anyone has more efficient code
For the following, please share:


  public String readTemplate(String pg) {
    File f = new File(pg);
    int l = (int)f.length( );
    byte[ ] buffer = new byte[l];

      try {
        FileInputStream in = new FileInputStream(pg);
        in.read(buffer, 0, l);
        }
        catch(Exception e) {
          System.out.println("Exception: " + e.getMessage( ) + "has
occurred");
          }

    String s = new String(buffer);
    return s;
  }



-Wil Moore

-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]] On Behalf Of
RBonazzo
Sent: Friday, March 08, 2002 12:55 AM
To: [EMAIL PROTECTED]
Subject: R:
Importance: High


You can use this for example
                        java.io.BufferedReader in =
                                new java.io.BufferedReader(new
java.io.FileReader("c:\\odd_directory\\web\\templates\\page.html"));
                        do {
                                Riga = in.readLine();
                                if (Riga == null) {
                                        in.close();
                                        break;
                                }
                                ContenutoFile = ContenutoFile + Riga +
"\n";
                        } while (true);
Hope that it can be help you.
Regards
Rinaldo
[EMAIL PROTECTED]

-----Messaggio originale-----
Da: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]] Per conto di
wilbert moore
Inviato: gioved� 7 marzo 2002 21.22
A: [EMAIL PROTECTED]
Oggetto: 


What I'm trying to do is probably pretty simple.
Its pretty easy to do in VB/ASP so I know this
will be a breeze for someone to answer.

My servlet is to read in an html file's contents which is sitting in a
folder under the main server's root. Since I have not yet been
successful in configuring tomcat to work under apache's control, my
servlet is at http://localhost:8080/servletname

If my html file is at http://localhost:80/page.html, what is the call I
need to make to find the raw directory (eg.
c:\odd_directory\web\templates\ )

I could obviously code this in hard, which I did to test so far,
however, if the app were moved, this would not work.

Thanks for the help, and I hope I supplied enough info for this simple
task.



__________________________________________
Launch your own web site Today!
Create a Web site for your family,
friends, photos, or a special event.
Visit: http://www.namezero.com/sitebuilder

________________________________________________________________________
___
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