You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Sean McGeever <se...@realise.com> on 2000/10/05 23:09:39 UTC

Tomcat3.1/IIS5/Win2K: IOException - servlet printing to template file?

Hi,
   any guidance/advice on resolving path/file references within a
servlet 
to a local template file in Tomcat on Win2K would be greatly
appreciated.

Background:
===========
I'm porting an application from Linux/Apache/JServ (1.1) to 
Win2K/IIS5/Tomcat 3.1.  This application actually comprises 3 distinct 
sites, each of which contains 1-4 distinct servlet zones (for security/
privacy).  Each servlet directory currently contains html template files 
(named *.tpl) which the servlet classes read in before populating with 
their dynamically-generated output.  Now, in the current setup, it's 
enough to specify the name of the template file with an absolute (Unix)
filename, e.g.: /path/to/servlet-zone/template-name.tpl

However, I've been unable to replicate this behaviour on the Win2K/IIS5/
Tomcat 3.1 setup.  Each servlet I call invariably throws an IOException 
when trying to read any of the template files (no matter where in the 
Tomcat filesystem I put these files).

Example:
========
<TOMCAT-HOME>   = D:\Tomcat
Context name    = /user
Context docBase = D:\Tomcat\webapps\user
Template file   = D:\Tomcat\webapps\user\reg_main.tpl

Code:
=====

// in template/output method...
try {

    BufferedReader objReader = new BufferedReader( new FileReader(
strPathFilename) );
    // print new output into objReader & return this as the servlet's
response...

} catch( IOException e ) {

    objStream.println("<HTML>\n<FONT FACE=\"Arial,Helvetica\" SIZE=2>");
    objStream.println("<H3>Templating error</H3>" + strPathFilename +
"\n");
    objStream.println("</FONT>\n</HTML>\n");

}

Output:
=======
If strPathFilename = "/webapps/user/reg_main.tpl", this _always_ results
in the following 
output:

"Templating error

/webapps/user/reg_main.tpl"


So, is there some Win2K or Tomcat or Servlet-specific way of doing this?

Thanks,

Sean