So your tag would be <img src='servlet(params);' alt='something'> ?
If you do this do the images get cached by the browser?
> It sounds like what you're asking is:
> How can you allow users to view images via the app without allowing them
> to
> look at them directly with a browser?
>
> If that's what you want to do, it can be accomplished by writing a servlet
> that streams images and use it as the "src" attribute to your image tags.
> This should get you started:
>
> package img;
> import java.io.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
> import javax.servlet.ServletException;
>
> public class ImageServlet extends HttpServlet{
>
> public void doGet(HttpServletRequest request,
> HttpServletResponse response)
> throws ServletException{
> try{
> response.setContentType("image/jpg");
> OutputStream o = response.getOutputStream();
>
> BufferedInputStream in = new BufferedInputStream(
> getServletContext()
> .getResourceAsStream(
> "/WEB-INF/forbidden_images/axis.jpg"));
>
> byte[] buf = new byte[32 * 1024]; // 32k buffer
> int nRead = 0;
> while( (nRead = in.read(buf)) != -1 ) {
> o.write(buf, 0, nRead);
> }
> o.flush();
> o.close();
> return;
> }catch(Exception e){
> // do something......
> }
> }
> }
> ~
> ~
> I'm not a streaming guru. It works but
> someone else might be able to show you a more
> elegant way to do it or how to do it from a JSP.
> You'll probably want to pass the image's file name in the querystring.
>
> Good Luck
> -Ben
>
>
>
>
>
>
>
>
> On Thursday 11 December 2003 01:29 pm, you wrote:
>> Howdy,
>> You asked how to block the user from seeing the images by putting the
>> address in the browser. I told you one possible way, e.g. by putting
>> them under WEB-INF. You can still access them from your servlets and
>> JSPs from this location, but users can't. What part is unclear?
>>
>> Yoav Shapira
>> Millennium ChemInformatics
>>
>> >-----Original Message-----
>>
>> From: Kiran Patel [mailto:[EMAIL PROTECTED]
>>
>> >Sent: Thursday, December 11, 2003 1:28 PM
>> >To: [EMAIL PROTECTED]
>> >Subject: Image Viewing
>> >
>> >Thank you for the replay and your help. If I move the images under
>>
>> WEB-INF
>>
>> >folder, I can't access the images from the application through the
>> >internet. The images can only be viewed if you login and start the
>> >application not by typing the url. For security purpose. Please help
>>
>> me
>>
>> >if anybody know how to do that. Thank you.
>> >
>> >Kiran Patel
>> >
>> >Howdy,
>> >Put the images directory under the WEB-INF directory and change your
>> >servlet accordingly.
>> >
>> >Yoav Shapira
>> >Millennium ChemInformatics
>> >
>> >>-----Original Message-----
>> >>From: Kiran Patel [mailto:[EMAIL PROTECTED]
>> >>Sent: Thursday, December 11, 2003 9:53 AM
>> >>To: [EMAIL PROTECTED]
>> >>Subject: Image Viewing
>> >>
>> >>I am using jsp and tomcat 4.1 for my web application. My application=
>> >
>> >is
>> >
>> >>viewing image which is in the webapps/image folder. This image can
>> >
>> >also be
>> >
>> >>viewed from the internet by just typing the url. I want to block thi=
>> >
>> >s
>> >
>> >>since these are the confidential images. Does anybody know how to do=
>> >
>> >that.
>> >
>> >>Thanks in advance.
>> >>
>> >>Kiran Patel
>>
>> This e-mail, including any attachments, is a confidential business
>> communication, and may contain information that is confidential,
>> proprietary and/or privileged. This e-mail is intended only for the
>> individual(s) to whom it is addressed, and may not be saved, copied,
>> printed, disclosed or used by anyone else. If you are not the(an)
>> intended
>> recipient, please immediately delete this e-mail from your computer
>> system
>> and notify the sender. Thank you.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]