Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Using ServletOutputStream in Servlet Vs <img src="../images/abc.gif" />

Reply
Thread Tools

Using ServletOutputStream in Servlet Vs <img src="../images/abc.gif" />

 
 
ap
Guest
Posts: n/a
 
      02-15-2005
Hi all,
Is anyone one know what is the different between them and which
one is faster or they have the same performance....

#############################################
public void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
response.setContentType("image/jpeg");
ServletOutputStream out = response.getOutputStream();
BufferedInputStream in = new BufferedInputStream(new
FileInputStream ("c:/images/abc.gif"));
while ((data = in.read()) != -1) {
out.write(data);
}
in.close();
out.close();
}
#############################################

and

#############################################
<img src="../images/abc.gif" /> in a .jsp file
#############################################

both of the file name are generated by some function
 
Reply With Quote
 
 
 
 
Ryan Stewart
Guest
Posts: n/a
 
      02-15-2005
"ap" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Hi all,
> Is anyone one know what is the different between them and which
> one is faster or they have the same performance....
>
> #############################################
> public void doGet(HttpServletRequest request, HttpServletResponse
> response)
> throws ServletException, IOException {
> response.setContentType("image/jpeg");
> ServletOutputStream out = response.getOutputStream();
> BufferedInputStream in = new BufferedInputStream(new
> FileInputStream ("c:/images/abc.gif"));
> while ((data = in.read()) != -1) {
> out.write(data);
> }
> in.close();
> out.close();
> }
> #############################################
>

This sends a response to the client containing an image (with the wrong
Content-Type).

> and
>
> #############################################
> <img src="../images/abc.gif" /> in a .jsp file
> #############################################
>

This causes the client to send an HTTP request for an image.

I'm not sure what you're looking for. The two aren't really related. You could
use a servlet mapping to cause the former to be used to respond to the latter.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to read from a ServletOutputstream? Timo Nentwig Java 6 08-22-2004 01:07 AM
ServletOutputStream & shtml files??? TomG Java 1 07-19-2004 07:32 AM
ServletOutputStream to Browser OK in NS, but not IE?? TomG Java 2 05-04-2004 06:09 PM
Servlet question(Tomcat, web.xml, servlet-class, servlet-name) circuit_breaker Java 2 04-04-2004 03:26 AM
Redirect ServletOutputStream into a file? Mikito Harakiri Java 1 04-03-2004 01:06 AM



Advertisments