-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 prt,
prt wrote: > I have another problem, You should post a separate message in this case. > I save uploaded images(by users) in folder place at "D:\storeg\data\uf\". > So when the URL is "http://localhost/test/uf/xyz.jpg" then is redirect to > "D:\storeg\data\uf\xyz.jpg" I assume you mean "it is mapped to d:\..."... redirecting to a local file path won't work unless you are running your browser from the application server. > And that so because i configure in server.xml this part between the host > tag, > <Context path="/uf" docBase="D:\storeg\data\uf" debug="0" > crossContext="false"/> > > Is there way that i can do that by using the filter, how can i redirect the > request from the filter when is "/uf..." to > "D:\storeg\data\uf..." with out loading the image and print it out from the > filter ? You have two options: 1. Map a directory into your URL space (not sure how to do that in Tomcat, but I'm sure that's been covered in the archives). 2. Write an image-serving servlet. Something like this: <servlet-mapping> <url-pattern>/ug/*</url-pattern> <servlet-name>imageServlet</servlet-name> </servlet-mapping> Your servlet class, written in loose pseudocode: doGet() { String filename = request.getExtraPathInfo(); // You should check for ".." and other evil-looking paths filename = "D:/storeg/data/ug/" + filename; File f = new File(filename); response.setContentType("whatever/is+appropriate"); response.setContentLength(f.length()); FileInputStream in = new FileInputStream(filename); OutputStream out = response.getOutputStream(); byte[] buffer = new byte[1024]; int count = 0; while(1024 == (count = in.read(buffer))) out.write(buffer); out.write(buffer, 0 count); in.close(); out.close(); } Hope that helps, - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF7fGd9CaO5/Lv0PARAs09AJ9O85lqIEw+ouuSo3oOJnvWQNkl+wCff4c8 8QYH36U+LBA0jk9GXbt69HQ= =Uz+L -----END PGP SIGNATURE----- --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]