Wow - great - thanks for the fast response - I will try it out.
Have a great weekend!
Kimberly

On Fri, Mar 21, 2008 at 9:12 PM, Lars Nielsen Lind
<[EMAIL PROTECTED]> wrote:
> Kimberly Begley skrev:
>
>
> > Hi,
>  > I'm trying to make a jsp display a plot that is a jpeg in a directory
>  > outside the catalina_home directory - I do not have the option of
>  > putting it in the webapp directory (there's 1000's of them - my page
>  > will just display one of them as selected by the user - along with
>  > some other info) - how do I go about displaying it?
>  > Thanks
>  >
>  > ---------------------------------------------------------------------
>  > To start a new topic, e-mail: users@tomcat.apache.org
>  > To unsubscribe, e-mail: [EMAIL PROTECTED]
>  > For additional commands, e-mail: [EMAIL PROTECTED]
>  >
>  >
>  >
>  You can do that with a Servlet. Here are some sample code. Replace
>  content of <> with your own data.
>
>
>
>  package <package name>;
>
>  import java.io.*;
>  import java.util.*;
>
>  import javax.servlet.*;
>  import javax.servlet.http.*;
>
>  public class OpenFile extends HttpServlet {
>
>     private String documentHome = ".";
>     private String page = "";
>     private String version = "";
>     private String remotehost = "";
>     private String remoteaddress = "";
>
>     protected File findFile(HttpServletRequest request) throws IOException {
>         File file = new File(<filename>);
>
>         return file;
>     }
>
>     protected void sendFile(File file, HttpServletResponse response)
>  throws IOException {
>         int c = 0;
>         FileInputStream fis = null;
>
>         try {
>             ServletOutputStream sos = response.getOutputStream();
>             fis = new FileInputStream(file);
>
>             while ((c = fis.read()) != -1) {
>                 sos.write(c);
>             }
>
>             sos.flush();
>         } finally {
>             if (fis != null) {
>                 fis.close();
>             }
>         }
>     }
>
>     public void service(HttpServletRequest request, HttpServletResponse
>  response) throws ServletException, IOException {
>         ServletConfig config = getServletConfig();
>         ServletContext application = config.getServletContext();
>         File file = findFile(request);
>
>         if (file == null) {
>         } else {
>
>
>  response.setContentType(application.getMimeType("application/" +
>  file.getName()));
>             response.setContentLength((int)file.length());
>             response.setHeader("Content-Disposition", "attachment;
>  filename = " + file.getName());
>             sendFile(file, response);
>         }
>     }
>
>  }
>
>  Hope that this is useful.
>
>  regards,
>
>  Lars Lind
>
>  ---------------------------------------------------------------------
>  To start a new topic, e-mail: users@tomcat.apache.org
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-- 
Kimberly Begley

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to