tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Warren <>
Subject Re: virtual host getRealPath
Date Sun, 05 Nov 2006 23:29:24 GMT
  The application is an image gallery.  I want to be able to drop images into directories
anywhere underneath the "gallery" webapp directory and have the images automatically displayed
as thumbnails in a table.  Users can click on a thumbnail for the full-size image.  I have
an index.jsp file that creates thumbnails for all the images in a directory and then generates
the html to display them.  Since I don't want to have to drop an index.jsp file into every
image directory, I set up a forwarding filter that forwards any request for a directory to
"/index.jsp" (the filter ignores other request urls).  To get the real path of the directory
that corresponds to the requested url, I use:
  String servletPath = (String) request.getAttribute("javax.servlet.forward.servlet_path");
  String realPath = application.getRealPath(servletPath);
  > You still have to add the request's URI to the end of that. 
  I don't seem to.  For example, a request for: yields a
servlet path of "/test/" and a real path of:
  C:\Documents and Settings\Peter\My Documents\dev\webapps\\gallery\pg
  which is just what I need.  Now with the real path, I can process the target image directory
by making thumbnails if necessary and laying out the html thumbnail table.
  It's up and working at

Cheap Talk? Check out Yahoo! Messenger's low  PC-to-Phone call rates.
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message