java servlet and HTTP communication:

java servlet and HTTP communication:

Post by peng zhipin » Tue, 05 Jun 2001 06:32:11



I have one question about java servlet,applet and http communicaton. In
my project, I have to retrive BLOB (image) from database, then via the
servlet to generate a HTML page. The page displays the images from
database, and each image has a link to start an applet.

How can I make a communication between the servlet and HTML page? In
trasfering text data, it is easier. If I do the following codes to
transfer Bytearry data to the browser, How can I make a link for each
image file?

 doPost(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
 try
  {

  //get the blob binary stream from database ,converts into Bytearray
 // ?? how can I here to make a link, so user can press iamge to call
  //another applet.

   res.setContentType(mimeContenttype);

   OutputStream out=res.getOutputStream();
   out.write(bytes); // bytes is an array which contain GIF file binary
//bits.
   out.flush();
  }
 catch (Exception ex){ }

....

thanks very much in advance!.

 
 
 

java servlet and HTTP communication:

Post by Uwe Plonu » Fri, 08 Jun 2001 03:15:21



> I have one question about java servlet,applet and http communicaton. In
> my project, I have to retrive BLOB (image) from database, then via the
> servlet to generate a HTML page. The page displays the images from
> database, and each image has a link to start an applet.

> How can I make a communication between the servlet and HTML page? In
> trasfering text data, it is easier. If I do the following codes to
> transfer Bytearry data to the browser, How can I make a link for each
> image file?

>  doPost(HttpServletRequest req, HttpServletResponse res)
>       throws ServletException, IOException {
>  try
>   {

>   //get the blob binary stream from database ,converts into Bytearray
>  // ?? how can I here to make a link, so user can press iamge to call
>   //another applet.

>    res.setContentType(mimeContenttype);

>    OutputStream out=res.getOutputStream();
>    out.write(bytes); // bytes is an array which contain GIF file binary
> //bits.
>    out.flush();
>   }
>  catch (Exception ex){ }

> ....

> thanks very much in advance!.

The images should be embedded in a html side. Around the links to the
images you can put the <a href=> tag.

Uwe

 
 
 

java servlet and HTTP communication:

Post by Ed Y » Fri, 08 Jun 2001 08:34:14


Write the servlet to set the content type as "image/jpg" (or whatever format
you need), then do a response.getOutputStream() and then write the image
out.



> > I have one question about java servlet,applet and http communicaton. In
> > my project, I have to retrive BLOB (image) from database, then via the
> > servlet to generate a HTML page. The page displays the images from
> > database, and each image has a link to start an applet.

> > How can I make a communication between the servlet and HTML page? In
> > trasfering text data, it is easier. If I do the following codes to
> > transfer Bytearry data to the browser, How can I make a link for each
> > image file?

> >  doPost(HttpServletRequest req, HttpServletResponse res)
> >       throws ServletException, IOException {
> >  try
> >   {

> >   //get the blob binary stream from database ,converts into Bytearray
> >  // ?? how can I here to make a link, so user can press iamge to call
> >   //another applet.

> >    res.setContentType(mimeContenttype);

> >    OutputStream out=res.getOutputStream();
> >    out.write(bytes); // bytes is an array which contain GIF file binary
> > //bits.
> >    out.flush();
> >   }
> >  catch (Exception ex){ }

> > ....

> > thanks very much in advance!.

> The images should be embedded in a html side. Around the links to the
> images you can put the <a href=> tag.

> Uwe