Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 67158 invoked from network); 3 Jun 2007 03:20:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Jun 2007 03:20:13 -0000 Received: (qmail 44823 invoked by uid 500); 3 Jun 2007 03:20:03 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 44792 invoked by uid 500); 3 Jun 2007 03:20:03 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 44781 invoked by uid 99); 3 Jun 2007 03:20:03 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Jun 2007 20:20:03 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of rashmi.sub@gmail.com designates 66.249.82.231 as permitted sender) Received: from [66.249.82.231] (HELO wx-out-0506.google.com) (66.249.82.231) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Jun 2007 20:19:57 -0700 Received: by wx-out-0506.google.com with SMTP id t16so970246wxc for ; Sat, 02 Jun 2007 20:19:36 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=uc7ri3uetYSJzmE0u3MLlboZ/5yV0Zcc6iuGR8lZJfiTI7ywZSm/f7AmeP60Y6JhsvVRVx88ZB+M3mmFHEm+9x5JSbthq/vttvkG9ssnnLbaEPdZvRbaZlrHn7ER7vQOLkpuwrmMXVGKdm0KkRvYLbWoOvToCNSDfhqGnTVEHiI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Ylqxxs31nZi9upEIiLd062kMPwQLHMJKKM5fXqHnS0i4lOmV6fESQLJurKH2eoMO57E74Y/I6nBxWl6DZVsfpY1IYsNxl1QePuGGxiOa0YwYjtEscUL/9HRHAz5sTVVJxJ1h/cRLvuaxl4WKQIkdnl2a3xr8Rl15wVLTVeXwCvk= Received: by 10.90.106.11 with SMTP id e11mr2818399agc.1180840776335; Sat, 02 Jun 2007 20:19:36 -0700 (PDT) Received: by 10.90.27.1 with HTTP; Sat, 2 Jun 2007 20:19:36 -0700 (PDT) Message-ID: <3ef28230706022019m3258ece2s79ef66c2bf8e3b01@mail.gmail.com> Date: Sat, 2 Jun 2007 23:19:36 -0400 From: "Rashmi Rubdi" To: "Tomcat Users List" Subject: Re: Making a directory visible to tomcat In-Reply-To: <5dd88dab0705291754m2b1d861dja32149bcfefabf64@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <5dd88dab0705291754m2b1d861dja32149bcfefabf64@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org On 5/29/07, Peter Dawn wrote: > guys, > > i am using tomcat 5.0. now i have created a file on my server at > C:\data\packet.xml. when somebody accesses my web app remotely, i want > the user to type in http://ipaddress:8080/packet.xml to be able to > access this file. One way to access the XML file at http://ipaddress:8080/packet.xml is to write either a Filter or a Servlet, and specify /packet.xml as the URL mapping for this Filter or Servlet in web.xml And inside the Filter or Servlet, you would use Java I/O to access a file that is outside the web application's context (in your case root context). For example: --------------------------------------------------------------------------------- ShowPacketXMLFilter.java --------------------------------------------------------------------------------- package somepackage; import javax.servlet.*; import java.io.*; public class ShowPacketXMLFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException { } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { servletResponse.setContentType("application/xhtml+xml"); PrintWriter out = servletResponse.getWriter(); BufferedReader br = new BufferedReader(new FileReader("C:/data/packet.xml")); String line; while ((line = br.readLine()) != null) { out.println(line); } } public void destroy() { } } -------------------------------------------------------------------------- web.xml -------------------------------------------------------------------------- ShowPacketXMLFilter somepackage.ShowPacketXMLFilter This filter reads packet.xml from disk and displays it's content at /packet.xml ShowPacketXMLFilter /packet.xml > can somebody please tell me how i can make a directory outside the > installation folder visible to tomcat. With Java I/O API you will be able to access any file , even if it is outside the web application's context. I don't know if there's a way to access any file outside the web app's context using Servlet API , others may know. > > thanks > -Rashmi --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org