Hi Steve,

Here is my humble first servlet - it displays an image and a couple of
lines of text.
The image it displays is stored in the web server's (IIS 4, in my case)
virtual directory
tree, in the images/ subdirectory.  (i.e. c:\InetPub\wwwroot\images\)

The servlet .class file is in the /servlets/ directory.

Here is the entire servlet:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Howdy extends HttpServlet {
        public void service(HttpServletRequest servReq,
                        HttpServletResponse servRes)
        throws IOException {

                servRes.setContentType("text/html");
                PrintWriter outstream = servRes.getWriter();
                int ii;

                outstream.println("<html>" +
                "<head><title>Mark's First Servlet</title><body>" +
                "<p ALIGN=\"CENTER\"><img SRC=\"/images/marklogo.jpg\"
WIDTH=\"300\" HEIGHT=\"500\"></p>" +
                "<p ALIGN=\"CENTER\">" +
                "<h1 ALIGN=\"CENTER\">MARK'S SERVLET</font></h1></p>" +
                "<c>Howdy, folks! Did this work?</c></p>");

                outstream.println("</body></html>");
                outstream.close();
        }
}

I hope that helps.

Mark

> -----Original Message-----
> From: Steve Buonincontri
> Sent: Tuesday, 18 May 1999 4:07
> To:   [EMAIL PROTECTED]
> Subject:      loading an image with a servlet
>
> folks,
>
> I have not been able to load an image from a servlet yet. I know this
> is an
> old topic, but can someone please send me the HTML line embedded
> inside the
> servlet which makes it happen?
>
> Where does the image have to reside? What does the line of java code
> look
> like?
>
> out.println("<IMG
> SRC=\"http://167.14.97.54:8080/vcafe3.0/Projects/LoginApplet/toppictur
> e.gif
> \" ...\">");
>
> Thanks.
>
> - steve
> ----------------------------------------------------------------
> The information transmitted is intended only for the person or entity
> to
> which it is addressed and may contain confidential and/or privileged
> material.  Any review, retransmission, dissemination or other use of,
> or
> taking of any action in reliance upon, this information by persons or
> entities other than the intended recipient is prohibited.   If you
> received
> this in error, please contact the sender and delete the material from
> any
> computer.
>
> ______________________________________________________________________
> _____
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources:
> http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to